A weird bug showed up in XSP (our ASP.NET server) when hit by a large POST with IE 6. Seems like IE decides that XSP is a HTTP/1.1 capable server and, who knows why, it sends a CRLF (\r\n) after the end of the POST data, beyond the Content-Length provided in the headers.
XSP was generating the response, writing it and then closing the socket. But IE thought it was a connection error as those 2 extra bytes were not being read.
After David Taylor (thanks David!) found this out I looked at Apache sources and, no surprise, this is not new for them. They already handle this case. In short, closing the connection may cause that not all the response data is read before the client gets the TCP RST packet and tears down the connection (read more on the IETF HTTP connection draft).
Now the code that closes the connection in XSP looks like:
const int max_useconds_to_linger = 30000000;
....
int waited = 0;
byte [] buffer = null;
Socket.Shutdown (SocketShutdown.Send);
while (waited < max_useconds_to_linger) {
int nread = 0;
try {
if (!Socket.Poll (useconds_to_linger, SelectMode.SelectRead))
break;
if (buffer == null)
buffer = new byte [512];
nread = Socket.Receive (buffer, 0, buffer.Length, 0);
} catch { }
if (nread == 0)
break;
waited += useconds_to_linger;
}
...Close the socket here...