private void update_website(FinalResultMessage message) { SecurityProtocol.set_protocol(); if (string.IsNullOrWhiteSpace(_configurationSettings.PackagesApiKey)) { return; } this.Log().Info(() => "Updating website for {0} v{1} with cleanup ({2}).".format_with(message.PackageId, message.PackageVersion, message.Reject ? "rejecting stale package" : "sending reminder")); try { var url = string.Join("/", SERVICE_ENDPOINT, message.PackageId, message.PackageVersion); HttpClient client = _nugetService.get_client(_configurationSettings.PackagesUrl, url, "POST", "application/x-www-form-urlencoded"); var postData = new StringBuilder(); postData.Append("apikey=" + HttpUtility.UrlEncode(_configurationSettings.PackagesApiKey)); postData.Append("&reject=" + HttpUtility.UrlEncode(message.Reject.to_string().to_lower())); postData.Append("&cleanupComments=" + HttpUtility.UrlEncode(message.ResultMessage)); var form = postData.ToString(); var data = Encoding.ASCII.GetBytes(form); client.SendingRequest += (sender, e) => { SendingRequest(this, e); var request = (HttpWebRequest)e.Request; request.Timeout = 30000; request.Headers.Add(_nugetService.ApiKeyHeader, _configurationSettings.PackagesApiKey); request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } }; _nugetService.ensure_successful_response(client); } catch (Exception ex) { Bootstrap.handle_exception(ex); } }
private void update_website(FinalResultMessage message) { if (string.IsNullOrWhiteSpace(_configurationSettings.PackagesApiKey)) return; this.Log().Info(() => "Updating website for {0} v{1} with cleanup ({2}).".format_with(message.PackageId, message.PackageVersion, message.Reject ? "rejecting stale package" : "sending reminder")); try { var url = string.Join("/", SERVICE_ENDPOINT, message.PackageId, message.PackageVersion); HttpClient client = _nugetService.get_client(_configurationSettings.PackagesUrl, url, "POST", "application/x-www-form-urlencoded"); var postData = new StringBuilder(); postData.Append("apikey=" + HttpUtility.UrlEncode(_configurationSettings.PackagesApiKey)); postData.Append("&reject=" + HttpUtility.UrlEncode(message.Reject.to_string().to_lower())); postData.Append("&cleanupComments=" + HttpUtility.UrlEncode(message.ResultMessage)); var form = postData.ToString(); var data = Encoding.ASCII.GetBytes(form); client.SendingRequest += (sender, e) => { SendingRequest(this, e); var request = (HttpWebRequest)e.Request; request.Timeout = 30000; request.Headers.Add(_nugetService.ApiKeyHeader, _configurationSettings.PackagesApiKey); request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } }; _nugetService.ensure_successful_response(client); } catch (Exception ex) { Bootstrap.handle_exception(ex); } }