[Mono-dev] XSP server patches that solve HTTP 400 Bad Request Issue
Vadym Stetsiak
vadmyst at gmail.com
Fri Dec 18 12:16:12 EST 2009
Hello,
Under moderate load XSP server starts corrupting incoming HTTP
requests. This results in 400 Bad Request responses from XSP server.
The reason is in HTTP header parsing code that does not correctly
handle situations when HTTP request data is received in small chunks.
Here are two patches for "/trunk/xsp/src/Mono.WebServer/XSPWorkerRequest.cs"
Index: XSPWorkerRequest.cs
===================================================================
--- XSPWorkerRequest.cs (revision 148762)
+++ XSPWorkerRequest.cs (working copy)
@@ -265,7 +265,8 @@
if (count >= 8192 || count + text.Length >= 8192)
throw new InvalidOperationException ("Line too long.");
- if (count <= 0) {
+ if (count <= 0 && b != '\r')
+ {
position = i + 1;
break;
}
@@ -275,7 +276,7 @@
if (i >= inputLength) {
b = inputBuffer [inputLength - 1];
- if (b != '\r' && b != '\n')
+ if (/*b != '\r' &&*/ b != '\n')
continue;
}
break;
And the second one for /trunk/xsp/src/Mono.WebServer/InitialWorkerRequest.cs
Index: InitialWorkerRequest.cs
===================================================================
--- InitialWorkerRequest.cs (revision 148762)
+++ InitialWorkerRequest.cs (working copy)
@@ -173,17 +173,18 @@
if (count >= 8192 || count + text.Length >= 8192)
throw new InvalidOperationException ("Line too long.");
- if (count <= 0) {
- position = i + 1;
- break;
- }
+ if (count <= 0 && b != '\r')
+ {
+ position = i + 1;
+ break;
+ }
text.Append (encoding.GetString (inputBuffer, position, count));
position = i + 1;
if (i >= inputLength) {
b = inputBuffer [inputLength - 1];
- if (b != '\r' && b != '\n')
+ if (/*b != '\r' &&*/ b != '\n')
continue;
}
break;
--
Vadym Stetsiak
More information about the Mono-devel-list
mailing list