Upgrade on CONNECT method

event_stream
Santiago Gala 15 years ago committed by Ryan Dahl
parent c83a018d05
commit 0264a0aefc

@ -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);
}

@ -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,18 +1407,27 @@ 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;
@ -1426,6 +1435,8 @@ test_scan (const struct message *r1, const struct message *r2, const struct mess
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",

Loading…
Cancel
Save