title: Read the HTTP POST request of HttpWebRequest
body: <p>I need to create Http POST requests and maybe a few GET requests as strings for some tests I am writing. Currently, my tests build them using a StringBuilder and hardcoded POST requests pulled out from fiddler kinda like this:</p>
  
  <pre><code>var builder = new StringBuilder();
  builder.Append("POST https://some.web.pg HTTP/1.1\r\n");
  builder.Append("Content-Type: application/x-www-form-urlencoded\r\n");
  builder.Append("Referer: https://some.referer.com\r\n");
  builder.Append("Accept-Language: en-us\r\n");
  builder.Append("Accept-Encoding: gzip, deflate\r\n");
  builder.Append("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)\r\n");
  builder.Append("Host: login.yahoo.com\r\n");
  //    ... other header info
  builder.Append("\r\n");
  builder.Append("post body......\r\n");
  var postData = builder.ToString();
  </code></pre>
  
  <p>This is quickly making my tests messy and would prefer to have a cleaner way to build these POST requests. I've been looking into HttpWebRequest class hoping that maybe it can create these for me. I figured that behind the sences it must have some way to construct this exact request I am trying to creating in some form or another. But alas, the GetRequestStream is a writable only stream.</p>
  
  <p>Is there a way to read the request stream HttpWebRequest will generate (and then change it to a string)? Or even any ideas on how to generate these POST requests would do.</p>