title: Copy HTTP request / response headers from a call to a HttpWebRequest?
body: <p>I have a C# WCF service that receives a request Message and post it to another service.
  Posting to the other service is done through HttpWebRequest.
  How can i get in my service the original request HTTP headers and put them in the HttpWebRequest when i post them to the other service.</p>
  
  <p>Something like this:</p>
  
  <pre><code>HttpRequestMessageProperty httpRequestProp = GetHttpRequestProp(requestMessage);
   HttpWebRequest loHttp = (HttpWebRequest)WebRequest.Create(uri);
    foreach (var item in httpRequestProp.Headers.AllKeys)
              {
  
                   loHttp.Headers.Add(item, httpRequestProp.Headers[item]);
              }
  </code></pre>
  
  <p>I know this doesn't work because HttpWebRequest loHttp has its own properties, and when i try to set ContentType for example in the above way it throws exception because it needs to be set like this:</p>
  
  <pre><code>loHttp.ContentType = httpRequestProp.Headers[HttpRequestHeader.ContentType];
  </code></pre>
  
  <p>So is there a way to copy the HTTP request headers from a call and put them as HTTP request headers to another HttpWebRequest ? Also the original request might have other custom headers set and i want send those also to the other service.</p>
  
  <p>Thank you,
  Adrya</p>