Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 2 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ env:
matrix:
- export NODE_VERSION="0.12"
- export NODE_VERSION="4.1"
- export NODE_VERSION="5.6"
- export NODE_VERSION="5.0"

matrix:
fast_finish: true
Expand Down
2 changes: 1 addition & 1 deletion 2 appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ environment:
- nodejs_version: "0.12"
# Node.js
- nodejs_version: "4.1"
- nodejs_version: "5.6"
- nodejs_version: "5.0"

matrix:
fast_finish: true
Expand Down
2 changes: 0 additions & 2 deletions 2 vendor/http_parser/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ parsertrace_g
*.mk
*.Makefile
*.so.*
*.exe.*
*.exe
*.a


Expand Down
1 change: 0 additions & 1 deletion 1 vendor/http_parser/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,3 @@ Romain Giraud <giraud.romain@gmail.com>
Jay Satiro <raysatiro@yahoo.com>
Arne Steen <Arne.Steen@gmx.de>
Kjell Schubert <kjell.schubert@gmail.com>
Olivier Mengué <dolmen@cpan.org>
31 changes: 9 additions & 22 deletions 31 vendor/http_parser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,7 @@
# IN THE SOFTWARE.

PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
HELPER ?=
BINEXT ?=
ifeq (darwin,$(PLATFORM))
SONAME ?= libhttp_parser.2.6.1.dylib
SOEXT ?= dylib
else ifeq (wine,$(PLATFORM))
CC = winegcc
BINEXT = .exe.so
HELPER = wine
else
SONAME ?= libhttp_parser.so.2.6.1
SOEXT ?= so
endif
SONAME ?= libhttp_parser.so.2.5.0

CC?=gcc
AR?=ar
Expand Down Expand Up @@ -65,8 +53,8 @@ LDFLAGS_LIB += -Wl,-soname=$(SONAME)
endif

test: test_g test_fast
$(HELPER) ./test_g$(BINEXT)
$(HELPER) ./test_fast$(BINEXT)
./test_g
./test_fast

test_g: http_parser_g.o test_g.o
$(CC) $(CFLAGS_DEBUG) $(LDFLAGS) http_parser_g.o test_g.o -o $@
Expand All @@ -93,7 +81,7 @@ 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 $(HELPER) ./test_fast$(BINEXT) > /dev/null; done
while(true) do time ./test_fast > /dev/null; done

test-valgrind: test_g
valgrind ./test_g
Expand All @@ -114,23 +102,23 @@ url_parser_g: http_parser_g.o contrib/url_parser.c
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o $@

parsertrace: http_parser.o contrib/parsertrace.c
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace$(BINEXT)
$(CC) $(CPPFLAGS_FAST) $(CFLAGS_FAST) $^ -o parsertrace

parsertrace_g: http_parser_g.o contrib/parsertrace.c
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g$(BINEXT)
$(CC) $(CPPFLAGS_DEBUG) $(CFLAGS_DEBUG) $^ -o parsertrace_g

tags: http_parser.c http_parser.h test.c
ctags $^

install: library
$(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h
$(INSTALL) -D $(SONAME) $(LIBDIR)/$(SONAME)
ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.$(SOEXT)
ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.so

install-strip: library
$(INSTALL) -D http_parser.h $(INCLUDEDIR)/http_parser.h
$(INSTALL) -D -s $(SONAME) $(LIBDIR)/$(SONAME)
ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.$(SOEXT)
ln -s $(LIBDIR)/$(SONAME) $(LIBDIR)/libhttp_parser.so

uninstall:
rm $(INCLUDEDIR)/http_parser.h
Expand All @@ -140,8 +128,7 @@ uninstall:
clean:
rm -f *.o *.a tags test test_fast test_g \
http_parser.tar libhttp_parser.so.* \
url_parser url_parser_g parsertrace parsertrace_g \
*.exe *.exe.so
url_parser url_parser_g parsertrace parsertrace_g

contrib/url_parser.c: http_parser.h
contrib/parsertrace.c: http_parser.h
Expand Down
71 changes: 4 additions & 67 deletions 71 vendor/http_parser/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
HTTP Parser
===========

[![Build Status](https://api.travis-ci.org/nodejs/http-parser.svg?branch=master)](https://travis-ci.org/nodejs/http-parser)
[![Build Status](https://travis-ci.org/joyent/http-parser.png?branch=master)](https://travis-ci.org/joyent/http-parser)

This is a parser for HTTP messages written in C. It parses both requests and
responses. The parser is designed to be used in performance HTTP
Expand Down Expand Up @@ -94,7 +94,7 @@ The Special Problem of Upgrade
------------------------------

HTTP supports upgrading the connection to a different protocol. An
increasingly common example of this is the WebSocket protocol which sends
increasingly common example of this is the Web Socket protocol which sends
a request like

GET /demo HTTP/1.1
Expand All @@ -106,8 +106,8 @@ a request like

followed by non-HTTP data.

(See [RFC6455](https://tools.ietf.org/html/rfc6455) for more information the
WebSocket protocol.)
(See http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75 for more
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
Expand Down Expand Up @@ -137,69 +137,6 @@ There are two types of callbacks:
Callbacks must return 0 on success. Returning a non-zero value indicates
error to the parser, making it exit immediately.

For cases where it is necessary to pass local information to/from a callback,
the `http_parser` object's `data` field can be used.
An example of such a case is when using threads to handle a socket connection,
parse a request, and then give a response over that socket. By instantiation
of a thread-local struct containing relevant data (e.g. accepted socket,
allocated memory for callbacks to write into, etc), a parser's callbacks are
able to communicate data between the scope of the thread and the scope of the
callback in a threadsafe manner. This allows http-parser to be used in
multi-threaded contexts.

Example:
```
typedef struct {
socket_t sock;
void* buffer;
int buf_len;
} custom_data_t;


int my_url_callback(http_parser* parser, const char *at, size_t length) {
/* access to thread local custom_data_t struct.
Use this access save parsed data for later use into thread local
buffer, or communicate over socket
*/
parser->data;
...
return 0;
}

...

void http_parser_thread(socket_t sock) {
int nparsed = 0;
/* allocate memory for user data */
custom_data_t *my_data = malloc(sizeof(custom_data_t));

/* some information for use by callbacks.
* achieves thread -> callback information flow */
my_data->sock = sock;

/* instantiate a thread-local parser */
http_parser *parser = malloc(sizeof(http_parser));
http_parser_init(parser, HTTP_REQUEST); /* initialise parser */
/* this custom data reference is accessible through the reference to the
parser supplied to callback functions */
parser->data = my_data;

http_parser_settings settings; / * set up callbacks */
settings.on_url = my_url_callback;

/* execute parser */
nparsed = http_parser_execute(parser, &settings, buf, recved);

...
/* parsed information copied from callback.
can now perform action on data copied into thread-local memory from callbacks.
achieves callback -> thread information flow */
my_data->buffer;
...
}

```

In case you parse HTTP message in chunks (i.e. `read()` request line
from socket, parse, read half headers, parse, etc) your data callbacks
may be called more than once. Http-parser guarantees that data pointer is only
Expand Down
3 changes: 1 addition & 2 deletions 3 vendor/http_parser/contrib/url_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ int main(int argc, char ** argv) {
connect = strcmp("connect", argv[1]) == 0 ? 1 : 0;
printf("Parsing %s, connect %d\n", argv[2], connect);

http_parser_url_init(&u);
result = http_parser_parse_url(argv[2], len, connect, &u);
if (result != 0) {
printf("Parse error : %d\n", result);
Expand All @@ -44,4 +43,4 @@ int main(int argc, char ** argv) {
printf("Parse ok, result : \n");
dump_url(argv[2], &u);
return 0;
}
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.