Prev: SETTING RULE FOR WHERE REPLY EMAILS ARE TO GO
Next: PRB: HttpWebRequest POST with AllowWriteStreamBuffering = False [.net 1.1, vs2003]
From: Chris Morse on 26 Jan 2010 09:46 Hi, This is a strange problem for me, because I know this was working correctly, but now when I am testing it, it is not working. Nothing changed in my code, it merely acts now as if I have not set "HttpWebRequest.AllowWriteStreamBuffering = False" and all data is sent quickly (ie, buffered locally). The whole point of turning off the buffering is so that I can provide a progress bar for larger uploads. Here is the basic code: Dim H As HttpWebRequest = HttpWebRequest.Create(szRequestURL) H.ContentType = "application/octet-stream" H.Method = "POST" H.Timeout = nTimeoutSec * 1000 H.AllowWriteStreamBuffering = False H.ContentLength = FI.Length Dim S As Stream = H.GetRequestStream() Dim timeStart As DateTime = DateTime.Now Dim TS As TimeSpan Dim nRead As Integer Dim BUFFER(4096) As Byte Dim nBytesSent As Integer = 0 Me.ProgressBar1.Minimum = 0 Me.ProgressBar1.Maximum = CInt(FI.Length) Me.ProgressBar1.Value = 0 Do nRead = myStreamReader.Read(BUFFER, 0, 4096) If nRead > 0 Then S.Write(BUFFER, 0, nRead) 'S.Flush() nBytesSent += nRead Me.ProgressBar1.Value = nBytesSent Application.DoEvents() Else Exit Do 'All data sent successfully End If Loop myStreamReader.Close() myStreamReader = Nothing I have done google searches and checked MSDN and everything seems to be correct in the code. Also, I know I had this working before, it used to send data slowly (my internet connection has a max upload speed of about 50KB/sec, so it takes a good 20 seconds to upload 1MB). Now a 5MB upload is completed in under 0.03 seconds, and, after the code above, the code hangs on the following line - while the uploads is actually completed. Dim WR As HttpWebResponse = CType(H.GetResponse(), HttpWebResponse) There is no authentication or redirections required, and I don't get any exceptions thrown. It simply acts as if I never issued the "H.AllowWriteStreamBuffering = False" call. Any ideas on what could be amiss? By the way-- This code is running under .NET 1.1 and VS2003. |