Skip to content

Commit

Permalink
deps: roll back http_parser to 2.3.0
Browse files Browse the repository at this point in the history
Commit 598efcb ("deps: update http_parser to 2.4.1") introduced a
regression in HTTP Upgrade header handling.

Fixes: #627
PR-URL: #628
Reviewed-By: Fedor Indutny <[email protected]>
  • Loading branch information
bnoordhuis committed Jan 28, 2015
1 parent 90ddb46 commit 6605096
Show file tree
Hide file tree
Showing 12 changed files with 265 additions and 656 deletions.
1 change: 0 additions & 1 deletion deps/http_parser/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ tags
test
test_g
test_fast
bench
url_parser
parsertrace
parsertrace_g
Expand Down
1 change: 0 additions & 1 deletion deps/http_parser/.mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ Salman Haq <[email protected]>
Simon Zimmermann <[email protected]>
Thomas LE ROUX <[email protected]> LE ROUX Thomas <[email protected]>
Thomas LE ROUX <[email protected]> Thomas LE ROUX <[email protected]>
Fedor Indutny <[email protected]>
2 changes: 1 addition & 1 deletion deps/http_parser/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ script:
notifications:
email: false
irc:
- "irc.freenode.net#node-ci"
- "irc.freenode.net#libuv"
15 changes: 1 addition & 14 deletions deps/http_parser/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,12 @@ BogDan Vatra <[email protected]>
Peter Faiman <[email protected]>
Corey Richardson <[email protected]>
Tóth Tamás <[email protected]>
Patrik Stutz <[email protected]>
Cam Swords <[email protected]>
Chris Dickinson <[email protected]>
Uli Köhler <[email protected]>
Charlie Somerville <[email protected]>
Patrik Stutz <[email protected]>
Fedor Indutny <[email protected]>
runner <[email protected]>
Alexis Campailla <[email protected]>
David Wragg <[email protected]>
Vinnie Falco <[email protected]>
Alex Butum <[email protected]>
Rex Feng <[email protected]>
Alex Kocharin <[email protected]>
Mark Koopman <[email protected]>
Helge Heß <[email protected]>
Alexis La Goutte <[email protected]>
George Miroshnykov <[email protected]>
Maciej Małecki <[email protected]>
Marc O'Morain <[email protected]>
Jeff Pinner <[email protected]>
Timothy J Fontaine <[email protected]>
Akagi201 <[email protected]>
4 changes: 4 additions & 0 deletions deps/http_parser/CONTRIBUTIONS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Contributors must agree to the Contributor License Agreement before patches
can be accepted.

http://spreadsheets2.google.com/viewform?hl=en&formkey=dDJXOGUwbzlYaWM4cHN1MERwQS1CSnc6MQ
13 changes: 1 addition & 12 deletions deps/http_parser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,20 @@
# IN THE SOFTWARE.

PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
SONAME ?= libhttp_parser.so.2.4.2
SONAME ?= libhttp_parser.so.2.3

CC?=gcc
AR?=ar

CPPFLAGS ?=
LDFLAGS ?=

CPPFLAGS += -I.
CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1
CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA)
CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
CPPFLAGS_BENCH = $(CPPFLAGS_FAST)

CFLAGS += -Wall -Wextra -Werror
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
CFLAGS_BENCH = $(CFLAGS_FAST) -Wno-unused-parameter
CFLAGS_LIB = $(CFLAGS_FAST) -fPIC

LDFLAGS_LIB = $(LDFLAGS) -shared
Expand Down Expand Up @@ -66,12 +61,6 @@ test_fast: http_parser.o test.o http_parser.h
test.o: test.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@

bench: http_parser.o bench.o
$(CC) $(CFLAGS_BENCH) $(LDFLAGS) http_parser.o bench.o -o $@

bench.o: bench.c http_parser.h Makefile
$(CC) $(CPPFLAGS_BENCH) $(CFLAGS_BENCH) -c bench.c -o $@

http_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c

Expand Down
10 changes: 5 additions & 5 deletions deps/http_parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if (recved < 0) {
}
/* Start up / continue the parser.
* Note we pass recved==0 to signal that EOF has been received.
* Note we pass recved==0 to signal that EOF has been recieved.
*/
nparsed = http_parser_execute(parser, &settings, buf, recved);
Expand All @@ -75,7 +75,7 @@ if (parser->upgrade) {
HTTP needs to know where the end of the stream is. For example, sometimes
servers send responses without Content-Length and expect the client to
consume input (for the body) until EOF. To tell http_parser about EOF, give
`0` as the fourth parameter to `http_parser_execute()`. Callbacks and errors
`0` as the forth parameter to `http_parser_execute()`. Callbacks and errors
can still be encountered during an EOF, so one must still be prepared
to receive them.

Expand Down Expand Up @@ -110,7 +110,7 @@ followed by non-HTTP data.
information the Web Socket protocol.)

To support this, the parser will treat this as a normal HTTP message without a
body, issuing both on_headers_complete and on_message_complete callbacks. However
body. Issuing both on_headers_complete and on_message_complete callbacks. However
http_parser_execute() will stop parsing at the end of the headers and return.

The user is expected to check if `parser->upgrade` has been set to 1 after
Expand All @@ -131,7 +131,7 @@ There are two types of callbacks:
* notification `typedef int (*http_cb) (http_parser*);`
Callbacks: on_message_begin, on_headers_complete, on_message_complete.
* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);`
Callbacks: (requests only) on_url,
Callbacks: (requests only) on_uri,
(common) on_header_field, on_header_value, on_body;

Callbacks must return 0 on success. Returning a non-zero value indicates
Expand All @@ -145,7 +145,7 @@ buffer to avoid copying memory around if this fits your application.

Reading headers may be a tricky task if you read/parse headers partially.
Basically, you need to remember whether last header callback was field or value
and apply the following logic:
and apply following logic:

(on_header_field and on_header_value shortened to on_h_*)
------------------------ ------------ --------------------------------------------
Expand Down
111 changes: 0 additions & 111 deletions deps/http_parser/bench.c

This file was deleted.

12 changes: 4 additions & 8 deletions deps/http_parser/contrib/parsertrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ int main(int argc, char* argv[]) {
FILE* file = fopen(filename, "r");
if (file == NULL) {
perror("fopen");
goto fail;
return EXIT_FAILURE;
}

fseek(file, 0, SEEK_END);
long file_length = ftell(file);
if (file_length == -1) {
perror("ftell");
goto fail;
return EXIT_FAILURE;
}
fseek(file, 0, SEEK_SET);

char* data = malloc(file_length);
if (fread(data, 1, file_length, file) != (size_t)file_length) {
fprintf(stderr, "couldn't read entire file\n");
free(data);
goto fail;
return EXIT_FAILURE;
}

http_parser_settings settings;
Expand All @@ -149,12 +149,8 @@ int main(int argc, char* argv[]) {
"Error: %s (%s)\n",
http_errno_description(HTTP_PARSER_ERRNO(&parser)),
http_errno_name(HTTP_PARSER_ERRNO(&parser)));
goto fail;
return EXIT_FAILURE;
}

return EXIT_SUCCESS;

fail:
fclose(file);
return EXIT_FAILURE;
}
Loading

0 comments on commit 6605096

Please sign in to comment.