Permalink
Browse files

Set http_major when a request omits the HTTP version

I.E. "GET /" in telnet
  • Loading branch information...
TooTallNate authored and ry committed Oct 18, 2010
1 parent cae8a96 commit 84578ae7a883a799c454f0e176782d01c801e61e
Showing with 29 additions and 0 deletions.
  1. +10 −0 http_parser.c
  2. +19 −0 test.c
View
@@ -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;
View
19 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 */
};

0 comments on commit 84578ae

Please sign in to comment.