Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Upgrade http_parser to 965f91bc76b2d1601e23
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 6, 2011
1 parent bbb38b8 commit c3ccbea
Show file tree
Hide file tree
Showing 7 changed files with 608 additions and 300 deletions.
38 changes: 22 additions & 16 deletions deps/http_parser/Makefile
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
CPPFLAGS?=-Wall -Wextra -Werror -I.
OPT_DEBUG=$(CPPFLAGS) -O0 -g -DHTTP_PARSER_STRICT=1
OPT_FAST=$(CPPFLAGS) -O3 -DHTTP_PARSER_STRICT=0

CC?=gcc
AR?=ar

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

CFLAGS += -Wall -Wextra -Werror
CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)


test: test_g test_fast
./test_g
./test_fast

test_g: http_parser_g.o test_g.o
$(CC) $(OPT_DEBUG) http_parser_g.o test_g.o -o $@
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@

test_g.o: test.c http_parser.h Makefile
$(CC) $(OPT_DEBUG) -c test.c -o $@

test.o: test.c http_parser.h Makefile
$(CC) $(OPT_FAST) -c test.c -o $@
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c test.c -o $@

http_parser_g.o: http_parser.c http_parser.h Makefile
$(CC) $(OPT_DEBUG) -c http_parser.c -o $@
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) -c http_parser.c -o $@

test-valgrind: test_g
valgrind ./test_g
test_fast: http_parser.o test.o http_parser.h
$(CC) $(CFLAGS_FAST) $(LDFLAGS) http_parser.o test.o -o $@

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

test_fast: http_parser.o test.c http_parser.h
$(CC) $(OPT_FAST) http_parser.o test.c -o $@
http_parser.o: http_parser.c http_parser.h Makefile
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) -c http_parser.c

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

test-valgrind: test_g
valgrind ./test_g

package: http_parser.o
$(AR) rcs libhttp_parser.a http_parser.o

Expand Down
4 changes: 2 additions & 2 deletions deps/http_parser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The parser extracts the following information from HTTP messages:
* Response status code
* Transfer-Encoding
* HTTP version
* Request path, query string, fragment
* Request URL
* Message body


Expand Down Expand Up @@ -126,7 +126,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_path, on_query_string, on_uri, on_fragment,
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 Down
Loading

0 comments on commit c3ccbea

Please sign in to comment.