diff --git a/http_parser.c b/http_parser.c index 176ca3c..ebdc4fb 100644 --- a/http_parser.c +++ b/http_parser.c @@ -441,6 +441,8 @@ size_t http_parser_execute (http_parser *parser, case s_start_req: { + if (ch == CR || ch == LF) + break; parser->flags = 0; parser->content_length = -1; diff --git a/test.c b/test.c index a4089fa..63d4800 100644 --- a/test.c +++ b/test.c @@ -443,6 +443,27 @@ const struct message requests[] = ,.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 */ };