Browse files

Upgrade on CONNECT method

  • Loading branch information...
1 parent c83a018 commit 0264a0aefcd119e179a3bc730ac517efbbccd4bb @sgala sgala committed with ry Jul 17, 2010
Showing with 15 additions and 4 deletions.
  1. +2 −2 http_parser.c
  2. +13 −2 test.c
View
4 http_parser.c
@@ -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
@@ -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);
}
View
15 test.c
@@ -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=" }
}
@@ -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;
@@ -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",

0 comments on commit 0264a0a

Please sign in to comment.