[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 04:31:39 -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-10 00:38:15.000000000 -0400
+++ shadow/59688.tmp.14432	2004-06-10 04:31:39.000000000 -0400
@@ -254,6 +254,41 @@
 }
 
 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.
 
+
+------- Additional Comments From davidandrewtaylor@hotmail.com  2004-06-10 04:31 -------
+I now know "exactly" what is happening!  IE sometimes sends an extra 
+\r\n at the end of the request.  You can see this in the tcpdump as 
+an additional packet that arrives at the end of the HTTP POST 
+(before the server sends its response).  But XSP is sending the 
+response and then closing the socket; however this is an error 
+because there are still 2 bytes on the connection waiting to be read 
+from Internet Explorer.  The reason my above "hack" worked was 
+because it was reading "all" bytes on the incoming stream.  Here is 
+a production quality fix:
+
+a) Change all references to NetworkStream to a new Class 
+XSPNetworkStream which we will create below.
+b) Create the following class:
+public class XSPNetworkStream : NetworkStream
+{
+  public XSPNetworkStream(Socket client, bool ownsSocket )
+    : base(client, ownsSocket) {}
+
+  public override void Close()
+  {
+    // Ignore extra CRLF that Internet Explorer adds to request.
+    if (Socket.Available!=0) Socket.Receive(new Byte[2]);
+    base.Close();
+  }
+}
+
+It should be pretty self evident what this is doing; it is first 
+checking if there are any available bytes and if so, reading 2 (if 
+they are available) before closing the connection.  This fixes the 
+XSP problem and closes this bug report :-)
+
+
+