Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Upgrade http-parser
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Feb 5, 2011
1 parent f99fc29 commit e42c74e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
17 changes: 14 additions & 3 deletions deps/http_parser/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,20 @@ size_t http_parser_execute (http_parser *parser,
uint64_t nread = parser->nread;

if (len == 0) {
if (state == s_body_identity_eof) {
CALLBACK2(message_complete);
switch (state) {
case s_body_identity_eof:
CALLBACK2(message_complete);
return 0;

case s_dead:
case s_start_req_or_res:
case s_start_res:
case s_start_req:
return 0;

default:
return 1; // error
}
return 0;
}

/* technically we could combine all of these (except for url_mark) into one
Expand Down Expand Up @@ -1384,6 +1394,7 @@ size_t http_parser_execute (http_parser *parser,
break;

default:
parser->state = state;
return p - data; /* Error */
}
}
Expand Down
10 changes: 9 additions & 1 deletion deps/http_parser/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,14 +1735,22 @@ main (void)

/// REQUESTS


test_simple("hello world", 0);
test_simple("GET / HTP/1.1\r\n\r\n", 0);


test_simple("ASDF / HTTP/1.1\r\n\r\n", 0);
test_simple("PROPPATCHA / HTTP/1.1\r\n\r\n", 0);
test_simple("GETA / HTTP/1.1\r\n\r\n", 0);

// Well-formed but incomplete
test_simple("GET / HTTP/1.1\r\n"
"Content-Type: text/plain\r\n"
"Content-Length: 6\r\n"
"\r\n"
"fooba",
0);

static const char *all_methods[] = {
"DELETE",
"GET",
Expand Down

0 comments on commit e42c74e

Please sign in to comment.