diff --git a/http_parser.c b/http_parser.c index b119060..492ef17 100644 --- a/http_parser.c +++ b/http_parser.c @@ -738,12 +738,14 @@ size_t http_parser_execute (http_parser *parser, case CR: CALLBACK(url); CALLBACK(path); + parser->http_major = 0; parser->http_minor = 9; state = s_req_line_almost_done; break; case LF: CALLBACK(url); CALLBACK(path); + parser->http_major = 0; parser->http_minor = 9; state = s_header_field_start; break; @@ -778,11 +780,13 @@ size_t http_parser_execute (http_parser *parser, break; case CR: CALLBACK(url); + parser->http_major = 0; parser->http_minor = 9; state = s_req_line_almost_done; break; case LF: CALLBACK(url); + parser->http_major = 0; parser->http_minor = 9; state = s_header_field_start; break; @@ -811,12 +815,14 @@ size_t http_parser_execute (http_parser *parser, case CR: CALLBACK(url); CALLBACK(query_string); + parser->http_major = 0; parser->http_minor = 9; state = s_req_line_almost_done; break; case LF: CALLBACK(url); CALLBACK(query_string); + parser->http_major = 0; parser->http_minor = 9; state = s_header_field_start; break; @@ -845,11 +851,13 @@ size_t http_parser_execute (http_parser *parser, break; case CR: CALLBACK(url); + parser->http_major = 0; parser->http_minor = 9; state = s_req_line_almost_done; break; case LF: CALLBACK(url); + parser->http_major = 0; parser->http_minor = 9; state = s_header_field_start; break; @@ -878,12 +886,14 @@ size_t http_parser_execute (http_parser *parser, case CR: CALLBACK(url); CALLBACK(fragment); + parser->http_major = 0; parser->http_minor = 9; state = s_req_line_almost_done; break; case LF: CALLBACK(url); CALLBACK(fragment); + parser->http_major = 0; parser->http_minor = 9; state = s_header_field_start; break; diff --git a/test.c b/test.c index 34f9db6..3e3df70 100644 --- a/test.c +++ b/test.c @@ -538,6 +538,25 @@ const struct message requests[] = ,.body= "" } +#define NO_HTTP_VERSION 19 +, {.name= "request with no http version" + ,.type= HTTP_REQUEST + ,.raw= "GET /\r\n" + "\r\n" + ,.should_keep_alive= FALSE + ,.message_complete_on_eof= FALSE + ,.http_major= 0 + ,.http_minor= 9 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/" + ,.request_url= "/" + ,.num_headers= 0 + ,.headers= {} + ,.body= "" + } + , {.name= NULL } /* sentinel */ };