コード例 #1
0
 public HttpWebResponse PerformRequest(Request request, Dictionary<string, string> additionalHeaders)
 {
     if (UrlRewriter != null)
     {
         String rewritten = UrlRewriter.RewriteUrl(request.Url);
         if (!String.IsNullOrEmpty(rewritten))
         {
             request.SetRedirectUrl(rewritten);
         }
     }
     var httpRequest = CreateHttpRequest(request);
     foreach (KeyValuePair<String, String> head in additionalHeaders)
     {
         try
         {
             httpRequest.Headers.Add(head.Key, head.Value);
         }
         catch (Exception)
         {
             continue;
         }
     }
     foreach (KeyValuePair<String, String> head in request.GetHeaders())
     {
         try
         {
             httpRequest.Headers.Add(head.Key, head.Value);
         }
         catch (Exception)
         {
             continue;
         }
     }
     return (HttpWebResponse)httpRequest.GetResponse();
 }