Browse Source

deps: update http_parser to 2.3.0

archived-io.js-v0.10
Fedor Indutny 11 years ago
parent
commit
2f0017aa53
  1. 1
      deps/http_parser/AUTHORS
  2. 2
      deps/http_parser/Makefile
  3. 61
      deps/http_parser/http_parser.c
  4. 4
      deps/http_parser/http_parser.h
  5. 52
      deps/http_parser/test.c

1
deps/http_parser/AUTHORS

@ -47,3 +47,4 @@ Charlie Somerville <charlie@charliesomerville.com>
Fedor Indutny <fedor.indutny@gmail.com>
runner <runner.mei@gmail.com>
Alexis Campailla <alexis@janeasystems.com>
David Wragg <david@wragg.org>

2
deps/http_parser/Makefile

@ -19,7 +19,7 @@
# IN THE SOFTWARE.
PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
SONAME ?= libhttp_parser.so.2.2.1
SONAME ?= libhttp_parser.so.2.3
CC?=gcc
AR?=ar

61
deps/http_parser/http_parser.c

@ -280,6 +280,9 @@ enum state
, s_header_field_start
, s_header_field
, s_header_value_discard_ws
, s_header_value_discard_ws_almost_done
, s_header_value_discard_lws
, s_header_value_start
, s_header_value
, s_header_value_lws
@ -1380,7 +1383,7 @@ size_t http_parser_execute (http_parser *parser,
}
if (ch == ':') {
parser->state = s_header_value_start;
parser->state = s_header_value_discard_ws;
CALLBACK_DATA(header_field);
break;
}
@ -1401,28 +1404,28 @@ size_t http_parser_execute (http_parser *parser,
goto error;
}
case s_header_value_start:
{
case s_header_value_discard_ws:
if (ch == ' ' || ch == '\t') break;
MARK(header_value);
parser->state = s_header_value;
parser->index = 0;
if (ch == CR) {
parser->header_state = h_general;
parser->state = s_header_almost_done;
CALLBACK_DATA(header_value);
parser->state = s_header_value_discard_ws_almost_done;
break;
}
if (ch == LF) {
parser->state = s_header_field_start;
CALLBACK_DATA(header_value);
parser->state = s_header_value_discard_lws;
break;
}
/* FALLTHROUGH */
case s_header_value_start:
{
MARK(header_value);
parser->state = s_header_value;
parser->index = 0;
c = LOWER(ch);
switch (parser->header_state) {
@ -1570,7 +1573,17 @@ size_t http_parser_execute (http_parser *parser,
STRICT_CHECK(ch != LF);
parser->state = s_header_value_lws;
break;
}
case s_header_value_lws:
{
if (ch == ' ' || ch == '\t') {
parser->state = s_header_value_start;
goto reexecute_byte;
}
/* finished the header */
switch (parser->header_state) {
case h_connection_keep_alive:
parser->flags |= F_CONNECTION_KEEP_ALIVE;
@ -1585,19 +1598,29 @@ size_t http_parser_execute (http_parser *parser,
break;
}
break;
parser->state = s_header_field_start;
goto reexecute_byte;
}
case s_header_value_lws:
case s_header_value_discard_ws_almost_done:
{
if (ch == ' ' || ch == '\t')
parser->state = s_header_value_start;
else
STRICT_CHECK(ch != LF);
parser->state = s_header_value_discard_lws;
break;
}
case s_header_value_discard_lws:
{
if (ch == ' ' || ch == '\t') {
parser->state = s_header_value_discard_ws;
break;
} else {
/* header value was empty */
MARK(header_value);
parser->state = s_header_field_start;
CALLBACK_DATA_NOADVANCE(header_value);
goto reexecute_byte;
}
break;
}
case s_headers_almost_done:

4
deps/http_parser/http_parser.h

@ -26,8 +26,8 @@ extern "C" {
/* Also update SONAME in the Makefile whenever you change these. */
#define HTTP_PARSER_VERSION_MAJOR 2
#define HTTP_PARSER_VERSION_MINOR 2
#define HTTP_PARSER_VERSION_PATCH 1
#define HTTP_PARSER_VERSION_MINOR 3
#define HTTP_PARSER_VERSION_PATCH 0
#include <sys/types.h>
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)

52
deps/http_parser/test.c

@ -608,8 +608,14 @@ const struct message requests[] =
" mno \r\n"
"\t \tqrs\r\n"
"Line2: \t line2\t\r\n"
"Line3:\r\n"
" line3\r\n"
"Line4: \r\n"
" \r\n"
,.should_keep_alive= TRUE
"Connection:\r\n"
" close\r\n"
"\r\n"
,.should_keep_alive= FALSE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
@ -618,9 +624,12 @@ const struct message requests[] =
,.fragment= ""
,.request_path= "/"
,.request_url= "/"
,.num_headers= 2
,.headers= { { "Line1", "abcdefghijklmno qrs" }
,.num_headers= 5
,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
, { "Line2", "line2\t" }
, { "Line3", "line3" }
, { "Line4", "" }
, { "Connection", "close" },
}
,.body= ""
}
@ -904,6 +913,43 @@ const struct message requests[] =
,.body= ""
}
#define LINE_FOLDING_IN_HEADER_WITH_LF 34
, {.name= "line folding in header value"
,.type= HTTP_REQUEST
,.raw= "GET / HTTP/1.1\n"
"Line1: abc\n"
"\tdef\n"
" ghi\n"
"\t\tjkl\n"
" mno \n"
"\t \tqrs\n"
"Line2: \t line2\t\n"
"Line3:\n"
" line3\n"
"Line4: \n"
" \n"
"Connection:\n"
" close\n"
"\n"
,.should_keep_alive= FALSE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.method= HTTP_GET
,.query_string= ""
,.fragment= ""
,.request_path= "/"
,.request_url= "/"
,.num_headers= 5
,.headers= { { "Line1", "abc\tdef ghi\t\tjkl mno \t \tqrs" }
, { "Line2", "line2\t" }
, { "Line3", "line3" }
, { "Line4", "" }
, { "Connection", "close" },
}
,.body= ""
}
, {.name= NULL } /* sentinel */
};

Loading…
Cancel
Save