Allow newlines before HTTP requests.

I have seen cases where a browser will POST data, and then send an
extra CRLF before issuing the next request.
event_stream
Cliff Frey 15 years ago committed by Ryan Dahl
parent f167565742
commit d5a900264f

@ -441,6 +441,8 @@ size_t http_parser_execute (http_parser *parser,
case s_start_req: case s_start_req:
{ {
if (ch == CR || ch == LF)
break;
parser->flags = 0; parser->flags = 0;
parser->content_length = -1; parser->content_length = -1;

@ -443,6 +443,27 @@ const struct message requests[] =
,.body= "" ,.body= ""
} }
#define PREFIX_NEWLINE_GET 15
/* Some clients, especially after a POST in a keep-alive connection,
* will send an extra CRLF before the next request
*/
, {.name = "newline prefix get"
,.type= HTTP_REQUEST
,.raw= "\r\nGET /test HTTP/1.1\r\n\r\n"
,.should_keep_alive= TRUE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_GET
,.query_string= ""
,.fragment= ""
,.request_path= "/test"
,.request_url= "/test"
,.num_headers= 0
,.headers= { }
,.body= ""
}
, {.name= NULL } /* sentinel */ , {.name= NULL } /* sentinel */
}; };

Loading…
Cancel
Save