Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Upgrade on CONNECT method
Browse files Browse the repository at this point in the history
  • Loading branch information
sgala authored and ry committed Jul 17, 2010
1 parent c83a018 commit 0264a0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ size_t http_parser_execute (http_parser *parser,

nread = 0;

if (parser->flags & F_UPGRADE) parser->upgrade = 1;
if (parser->flags & F_UPGRADE || parser->method == HTTP_CONNECT) parser->upgrade = 1;

/* Here we call the headers_complete callback. This is somewhat
* different than other callbacks because if the user returns 1, we
Expand All @@ -1339,7 +1339,7 @@ size_t http_parser_execute (http_parser *parser,
}

// Exit, the rest of the connect is in a different protocol.
if (parser->flags & F_UPGRADE) {
if (parser->flags & F_UPGRADE || parser->method == HTTP_CONNECT) {
CALLBACK2(message_complete);
return (p - data);
}
Expand Down
15 changes: 13 additions & 2 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ const struct message requests[] =
,.request_path= ""
,.request_url= "home.netscape.com:443"
,.num_headers= 2
,.upgrade=0
,.upgrade=1
,.headers= { { "User-agent", "Mozilla/1.1N" }
, { "Proxy-authorization", "basic aGVsbG86d29ybGQ=" }
}
Expand Down Expand Up @@ -1407,25 +1407,36 @@ test_scan (const struct message *r1, const struct message *r2, const struct mess
buf3[buf3_len] = 0;

read = parse(buf1, buf1_len);

if (r3->upgrade && parser->upgrade) goto test;

if (read != buf1_len) {
print_error(buf1, read);
goto error;
}

read = parse(buf2, buf2_len);

if (r3->upgrade && parser->upgrade) goto test;

if (read != buf2_len) {
print_error(buf2, read);
goto error;
}

read = parse(buf3, buf3_len);

if (r3->upgrade && parser->upgrade) goto test;

if (read != buf3_len) {
print_error(buf3, read);
goto error;
}

parse(NULL, 0);

test:

if (3 != num_messages) {
fprintf(stderr, "\n\nParser didn't see 3 messages only %d\n", num_messages);
goto error;
Expand Down Expand Up @@ -1595,7 +1606,7 @@ main (void)
"HEAD",
"POST",
"PUT",
"CONNECT",
//"CONNECT", //CONNECT can't be tested like other methods, it's a tunnel
"OPTIONS",
"TRACE",
"COPY",
Expand Down

0 comments on commit 0264a0a

Please sign in to comment.