title: HttpWebRequest stream write never completes
body: <p>I'm posting a file with <code>HttpWebRequest</code>, along with a header and footer. The header (ca. 0.5K) and the actual file seem to write fine, but with large files (ca. 15MB), the footer (which is like 29 bytes) never seems to write.</p>
  
  <pre><code>using (Stream requestStream = request.GetRequestStream()) {
      requestStream.Write(postHeaderBytes, 0, postHeaderBytes.Length);
  
      byte[] buffer = new byte[Math.Min(4096L, fileSize)];
      int bytesRead = 0;
      while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0) {
          requestStream.Write(buffer, 0, bytesRead);
      }
  
      // next line never completes                        
      requestStream.Write(postFooterBytes, 0, postFooterBytes.Length);
  
      // code below is never reached
      Console.WriteLine("Why do I never see this message in the console?");
  }
  </code></pre>
  
  <p>Any thoughts?</p>
  
  <p><strong>ETA:</strong> Tried flushing the stream before the last <code>Write()</code>, on the off chance it would help, but to no effect.</p>
  
  <p><strong>Edited again:</strong> Added <code>using()</code> to clarify that I'm not a <em>complete</em> idiot. Note also BTW that this is inside <em>another</em> <code>using()</code> block for <code>fileStream</code>.</p>