[Mono-bugs] [Bug 59688][Blo] Changed - Critical Bug causing large HTTP POSTs to fail in Internet Explorer

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 10 Jun 2004 00:38:15 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by davidandrewtaylor@hotmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=59688

--- shadow/59688	2004-06-09 23:41:25.000000000 -0400
+++ shadow/59688.tmp.11894	2004-06-10 00:38:15.000000000 -0400
@@ -217,6 +217,43 @@
 ------- Additional Comments From gonzalo@ximian.com  2004-06-09 22:05 -------
 Yay! Just when I was going to write that i find you're already there. 
 
 ------- Additional Comments From gonzalo@ximian.com  2004-06-09 23:41 -------
 Update: can only reproduce it inside vmware itself (win2k). If I run
 xsp in the host machine (linux) it works perfectly).
+
+------- Additional Comments From davidandrewtaylor@hotmail.com  2004-06-10 00:38 -------
+I have found what it is.  Basically, when reading from a 
+NetworkStream the number of bytes available will depend on how many 
+have arrived at the server/client.  This is why it is intermittent 
+and is occuring for large POST packets.  I think we need to be 
+smarter about reading the number of bytes received (and checking the 
+HTTP Length) and then blocking until the entire contents are 
+received.  For example, just by making this change to XSP in the 
+InitialWorkerRequest class it seems to fix the problem:
+
+// Original Code
+void FillBuffer ()
+{
+  inputBuffer = new byte [BSize];
+  inputLength = stream.Read (inputBuffer, 0, BSize);
+  position = 0;
+}
+
+// Change to this
+void FillBuffer ()
+{
+  int index=0;
+  inputBuffer = new byte[1000000];
+  for (int i = 0; i<10; i++)
+  {
+    while (stream.DataAvailable)
+      inputBuffer[index++] = (byte)stream.ReadByte();
+    System.Threading.Thread.Sleep(100);
+  }
+  inputLength = index;
+}
+
+Now of course the above code is a hack; but it does fix the problem 
+and demonstrates what needs to be done to make XSP a reliable web 
+server.
+