title: Request stream fail to write
body: <p>I have to upload a large file to the server with the following code snippet:</p>
  
  <pre><code>static async Task LordNoBugAsync(string token, string filePath, string uri)
  {
      HttpWebRequest fileWebRequest = (HttpWebRequest)WebRequest.Create(uri);
      fileWebRequest.Method = "PATCH";
      fileWebRequest.AllowWriteStreamBuffering = false; //this line tells to upload by chunks
      fileWebRequest.ContentType = "application/x-www-form-urlencoded";
      fileWebRequest.Headers["Authorization"] = "PHOENIX-TOKEN " + token;
      fileWebRequest.KeepAlive = false;
      fileWebRequest.Timeout = System.Threading.Timeout.Infinite;
      fileWebRequest.Proxy = null;
  
      using (FileStream fileStream = File.OpenRead(filePath) )
      {
          fileWebRequest.ContentLength = fileStream.Length; //have to provide length in order to upload by chunks
          int bufferSize = 512000;
          byte[] buffer = new byte[bufferSize];
          int lastBytesRead = 0;
          int byteCount = 0;
          Stream requestStream = fileWebRequest.GetRequestStream();
          requestStream.WriteTimeout = System.Threading.Timeout.Infinite;
  
          while ((lastBytesRead = fileStream.Read(buffer, 0, bufferSize)) != 0)
          {
              if (lastBytesRead &gt; 0)
              {
                  await requestStream.WriteAsync(buffer, 0, lastBytesRead);
                  //for some reasons didnt really write to stream, but in fact buffer has content, &gt;60MB                   
                  byteCount += bufferSize;
              }
          }
          requestStream.Flush();
          try
          {                    
              requestStream.Close();
              requestStream.Dispose();
          }
          catch
          {
              Console.Write("Error");
          }
          try
          {
              fileStream.Close();
              fileStream.Dispose();
          }
          catch
          {
              Console.Write("Error");
          }
      }
      ...getting response parts...
  }
  </code></pre>
  
  <p>In the code, I made a HttpWebRequest and push the content to server with buffering. The code works perfectly for any files under 60MB.</p>
  
  <p>I tried a 70MB pdf. The buffer array has different content for each buffering. Yet, the request stream does not seem to be getting written. The bytecount also reached 70M, showing the file is properly read. </p>
  
  <p>Edit (more info): I set the break point at requestStream.Close(). It clearly takes ~2 mins for the request stream to write in 60MB files but only takes 2ms for 70MB files.</p>
  
  <p>My calling:</p>
  
  <pre><code>        Task magic = LordNoBugAsync(token, nameofFile, path);
          magic.Wait();
  </code></pre>
  
  <p>I am sure my calling is correct (it works for 0B to 60MB files).</p>
  
  <p>Any advice or suggestion is much appreciated.</p>