From 59569f2125211ed7ce4163f34d0cc6f4b6801f1c Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Sat, 24 Jan 2015 16:29:47 +0300 Subject: [PATCH] src: skip lws between `connection` values Fix: https://github.com/iojs/io.js/issues/588 PR-URL: https://github.com/joyent/http-parser/pull/216 Reviewed-By: Ben Noordhuis --- http_parser.c | 2 ++ test.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/http_parser.c b/http_parser.c index 3e114c0..c0e7ca1 100644 --- a/http_parser.c +++ b/http_parser.c @@ -1618,6 +1618,8 @@ size_t http_parser_execute (http_parser *parser, h_state = h_matching_connection_upgrade; } else if (STRICT_TOKEN(c)) { h_state = h_matching_connection_token; + } else if (c == ' ' || c == '\t') { + /* Skip lws */ } else { h_state = h_general; } diff --git a/test.c b/test.c index 6c45d59..aae0f73 100644 --- a/test.c +++ b/test.c @@ -986,6 +986,55 @@ const struct message requests[] = ,.body= "" } +#define CONNECTION_MULTI_LWS 36 +, {.name = "multiple connection header values with folding and lws" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Connection: keep-alive, upgrade\r\n" + "Upgrade: WebSocket\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 2 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Connection", "keep-alive, upgrade" } + , { "Upgrade", "WebSocket" } + } + ,.body= "" + } + +#define CONNECTION_MULTI_LWS_CRLF 37 +, {.name = "multiple connection header values with folding and lws" + ,.type= HTTP_REQUEST + ,.raw= "GET /demo HTTP/1.1\r\n" + "Connection: keep-alive, \r\n upgrade\r\n" + "Upgrade: WebSocket\r\n" + "\r\n" + "Hot diggity dogg" + ,.should_keep_alive= TRUE + ,.message_complete_on_eof= FALSE + ,.http_major= 1 + ,.http_minor= 1 + ,.method= HTTP_GET + ,.query_string= "" + ,.fragment= "" + ,.request_path= "/demo" + ,.request_url= "/demo" + ,.num_headers= 2 + ,.upgrade="Hot diggity dogg" + ,.headers= { { "Connection", "keep-alive, upgrade" } + , { "Upgrade", "WebSocket" } + } + ,.body= "" + } , {.name= NULL } /* sentinel */ };