Skip to content

Commit 79cbe1f

Browse files
committed
deps: upgrade http_parser to 8bec3ea
1 parent 407ecc6 commit 79cbe1f

5 files changed

Lines changed: 120 additions & 106 deletions

File tree

deps/http_parser/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
core
12
tags
23
*.o
34
test
45
test_g
56
test_fast
7+
*.mk
8+
*.Makefile

deps/http_parser/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,5 +174,5 @@ consecutive `on_url` callbacks.
174174
See examples of reading in headers:
175175

176176
* [partial example](http://gist.github.com/155877) in C
177-
* [from http-parser tests](http://github.com/ry/http-parser/blob/37a0ff8928fb0d83cec0d0d8909c5a4abcd221af/test.c#L403) in C
178-
* [from Node library](http://github.com/ry/node/blob/842eaf446d2fdcb33b296c67c911c32a0dabc747/src/http.js#L284) in Javascript
177+
* [from http-parser tests](http://github.com/joyent/http-parser/blob/37a0ff8/test.c#L403) in C
178+
* [from Node library](http://github.com/joyent/node/blob/842eaf4/src/http.js#L284) in Javascript

deps/http_parser/http_parser.c

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,10 @@ do { \
123123

124124

125125
static const char *method_strings[] =
126-
{ "DELETE"
127-
, "GET"
128-
, "HEAD"
129-
, "POST"
130-
, "PUT"
131-
, "CONNECT"
132-
, "OPTIONS"
133-
, "TRACE"
134-
, "COPY"
135-
, "LOCK"
136-
, "MKCOL"
137-
, "MOVE"
138-
, "PROPFIND"
139-
, "PROPPATCH"
140-
, "UNLOCK"
141-
, "REPORT"
142-
, "MKACTIVITY"
143-
, "CHECKOUT"
144-
, "MERGE"
145-
, "M-SEARCH"
146-
, "NOTIFY"
147-
, "SUBSCRIBE"
148-
, "UNSUBSCRIBE"
149-
, "PATCH"
150-
, "PURGE"
126+
{
127+
#define XX(num, name, string) #string,
128+
HTTP_METHOD_MAP(XX)
129+
#undef XX
151130
};
152131

153132

@@ -918,7 +897,7 @@ size_t http_parser_execute (http_parser *parser,
918897
/* or PROPFIND|PROPPATCH|PUT|PATCH|PURGE */
919898
break;
920899
case 'R': parser->method = HTTP_REPORT; break;
921-
case 'S': parser->method = HTTP_SUBSCRIBE; break;
900+
case 'S': parser->method = HTTP_SUBSCRIBE; /* or SEARCH */ break;
922901
case 'T': parser->method = HTTP_TRACE; break;
923902
case 'U': parser->method = HTTP_UNLOCK; /* or UNSUBSCRIBE */ break;
924903
default:
@@ -965,6 +944,12 @@ size_t http_parser_execute (http_parser *parser,
965944
} else {
966945
goto error;
967946
}
947+
} else if (parser->method == HTTP_SUBSCRIBE) {
948+
if (parser->index == 1 && ch == 'E') {
949+
parser->method = HTTP_SEARCH;
950+
} else {
951+
goto error;
952+
}
968953
} else if (parser->index == 1 && parser->method == HTTP_POST) {
969954
if (ch == 'R') {
970955
parser->method = HTTP_PROPFIND; /* or HTTP_PROPPATCH */

deps/http_parser/http_parser.h

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ typedef int ssize_t;
6565

6666
typedef struct http_parser http_parser;
6767
typedef struct http_parser_settings http_parser_settings;
68-
typedef struct http_parser_result http_parser_result;
6968

7069

7170
/* Callbacks should return non-zero to indicate an error. The parser will
@@ -86,37 +85,44 @@ typedef int (*http_cb) (http_parser*);
8685

8786

8887
/* Request Methods */
88+
#define HTTP_METHOD_MAP(XX) \
89+
XX(0, DELETE, DELETE) \
90+
XX(1, GET, GET) \
91+
XX(2, HEAD, HEAD) \
92+
XX(3, POST, POST) \
93+
XX(4, PUT, PUT) \
94+
/* pathological */ \
95+
XX(5, CONNECT, CONNECT) \
96+
XX(6, OPTIONS, OPTIONS) \
97+
XX(7, TRACE, TRACE) \
98+
/* webdav */ \
99+
XX(8, COPY, COPY) \
100+
XX(9, LOCK, LOCK) \
101+
XX(10, MKCOL, MKCOL) \
102+
XX(11, MOVE, MOVE) \
103+
XX(12, PROPFIND, PROPFIND) \
104+
XX(13, PROPPATCH, PROPPATCH) \
105+
XX(14, SEARCH, SEARCH) \
106+
XX(15, UNLOCK, UNLOCK) \
107+
/* subversion */ \
108+
XX(16, REPORT, REPORT) \
109+
XX(17, MKACTIVITY, MKACTIVITY) \
110+
XX(18, CHECKOUT, CHECKOUT) \
111+
XX(19, MERGE, MERGE) \
112+
/* upnp */ \
113+
XX(20, MSEARCH, M-SEARCH) \
114+
XX(21, NOTIFY, NOTIFY) \
115+
XX(22, SUBSCRIBE, SUBSCRIBE) \
116+
XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \
117+
/* RFC-5789 */ \
118+
XX(24, PATCH, PATCH) \
119+
XX(25, PURGE, PURGE) \
120+
89121
enum http_method
90-
{ HTTP_DELETE = 0
91-
, HTTP_GET
92-
, HTTP_HEAD
93-
, HTTP_POST
94-
, HTTP_PUT
95-
/* pathological */
96-
, HTTP_CONNECT
97-
, HTTP_OPTIONS
98-
, HTTP_TRACE
99-
/* webdav */
100-
, HTTP_COPY
101-
, HTTP_LOCK
102-
, HTTP_MKCOL
103-
, HTTP_MOVE
104-
, HTTP_PROPFIND
105-
, HTTP_PROPPATCH
106-
, HTTP_UNLOCK
107-
/* subversion */
108-
, HTTP_REPORT
109-
, HTTP_MKACTIVITY
110-
, HTTP_CHECKOUT
111-
, HTTP_MERGE
112-
/* upnp */
113-
, HTTP_MSEARCH
114-
, HTTP_NOTIFY
115-
, HTTP_SUBSCRIBE
116-
, HTTP_UNSUBSCRIBE
117-
/* RFC-5789 */
118-
, HTTP_PATCH
119-
, HTTP_PURGE
122+
{
123+
#define XX(num, name, string) HTTP_##name = num,
124+
HTTP_METHOD_MAP(XX)
125+
#undef XX
120126
};
121127

122128

0 commit comments

Comments
 (0)