Skip to content

Commit c3ccbea

Browse files
committed
Upgrade http_parser to 965f91bc76b2d1601e23
1 parent bbb38b8 commit c3ccbea

7 files changed

Lines changed: 608 additions & 300 deletions

File tree

deps/http_parser/Makefile

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,45 @@
1-
CPPFLAGS?=-Wall -Wextra -Werror -I.
2-
OPT_DEBUG=$(CPPFLAGS) -O0 -g -DHTTP_PARSER_STRICT=1
3-
OPT_FAST=$(CPPFLAGS) -O3 -DHTTP_PARSER_STRICT=0
4-
51
CC?=gcc
62
AR?=ar
73

4+
CPPFLAGS += -I.
5+
CPPFLAGS_DEBUG = $(CPPFLAGS) -DHTTP_PARSER_STRICT=1 -DHTTP_PARSER_DEBUG=1
6+
CPPFLAGS_DEBUG += $(CPPFLAGS_DEBUG_EXTRA)
7+
CPPFLAGS_FAST = $(CPPFLAGS) -DHTTP_PARSER_STRICT=0 -DHTTP_PARSER_DEBUG=0
8+
CPPFLAGS_FAST += $(CPPFLAGS_FAST_EXTRA)
9+
10+
CFLAGS += -Wall -Wextra -Werror
11+
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
12+
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
13+
814

915
test: test_g test_fast
1016
./test_g
1117
./test_fast
1218

1319
test_g: http_parser_g.o test_g.o
14-
$(CC) $(OPT_DEBUG) http_parser_g.o test_g.o -o $@
20+
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
1521

1622
test_g.o: test.c http_parser.h Makefile
17-
$(CC) $(OPT_DEBUG) -c test.c -o $@
18-
19-
test.o: test.c http_parser.h Makefile
20-
$(CC) $(OPT_FAST) -c test.c -o $@
23+
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@
2124

2225
http_parser_g.o: http_parser.c http_parser.h Makefile
23-
$(CC) $(OPT_DEBUG) -c http_parser.c -o $@
26+
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@
2427

25-
test-valgrind: test_g
26-
valgrind ./test_g
28+
test_fast: http_parser.o test.o http_parser.h
29+
$(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@
2730

28-
http_parser.o: http_parser.c http_parser.h Makefile
29-
$(CC) $(OPT_FAST) -c http_parser.c
31+
test.o: test.c http_parser.h Makefile
32+
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c test.c -o $@
3033

31-
test_fast: http_parser.o test.c http_parser.h
32-
$(CC) $(OPT_FAST) http_parser.o test.c -o $@
34+
http_parser.o: http_parser.c http_parser.h Makefile
35+
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c
3336

3437
test-run-timed: test_fast
3538
while(true) do time ./test_fast > /dev/null; done
3639

40+
test-valgrind: test_g
41+
valgrind ./test_g
42+
3743
package: http_parser.o
3844
$(AR) rcs libhttp_parser.a http_parser.o
3945

deps/http_parser/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The parser extracts the following information from HTTP messages:
2424
* Response status code
2525
* Transfer-Encoding
2626
* HTTP version
27-
* Request path, query string, fragment
27+
* Request URL
2828
* Message body
2929

3030

@@ -126,7 +126,7 @@ There are two types of callbacks:
126126
* notification `typedef int (*http_cb) (http_parser*);`
127127
Callbacks: on_message_begin, on_headers_complete, on_message_complete.
128128
* data `typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);`
129-
Callbacks: (requests only) on_path, on_query_string, on_uri, on_fragment,
129+
Callbacks: (requests only) on_uri,
130130
(common) on_header_field, on_header_value, on_body;
131131

132132
Callbacks must return 0 on success. Returning a non-zero value indicates

0 commit comments

Comments
 (0)