summaryrefslogtreecommitdiff
path: root/deps/http_parser
diff options
context:
space:
mode:
authorNathan Rajlich <nathan@tootallnate.net>2010-10-13 02:45:37 -0700
committerRyan Dahl <ry@tinyclouds.org>2010-10-13 02:47:10 -0700
commit9b1ff070e6df8560ec4ce60d78c68c96ddf206c8 (patch)
tree94d7225ad47b68c5ef2101fefb65efcd64d47d91 /deps/http_parser
parent73b29d79b96e2db853ef38c59d76d136f45caeae (diff)
downloadnode-new-9b1ff070e6df8560ec4ce60d78c68c96ddf206c8.tar.gz
Upgrade http-parser with a fix for spaces in headers
Diffstat (limited to 'deps/http_parser')
-rw-r--r--deps/http_parser/http_parser.c20
-rw-r--r--deps/http_parser/http_parser.h7
2 files changed, 14 insertions, 13 deletions
diff --git a/deps/http_parser/http_parser.c b/deps/http_parser/http_parser.c
index c600ff19b2..02532d3a2c 100644
--- a/deps/http_parser/http_parser.c
+++ b/deps/http_parser/http_parser.c
@@ -108,7 +108,7 @@ static const char *method_strings[] =
/* ' ', '_', '-' and all alpha-numeric ascii characters are accepted by acceptable_header.
The 'A'-'Z' are lower-cased. */
-static const unsigned char acceptable_header[256] = {
+static const char acceptable_header[256] = {
/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */
0, 0, 0, 0, 0, 0, 0, 0,
/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */
@@ -143,7 +143,7 @@ static const unsigned char acceptable_header[256] = {
'x', 'y', 'z', 0, 0, 0, 0, 0 };
-static const int unhex[256] =
+static const int8_t unhex[256] =
{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
@@ -155,7 +155,7 @@ static const int unhex[256] =
};
-static const int normal_url_char[256] = {
+static const uint8_t normal_url_char[256] = {
/* 0 nul 1 soh 2 stx 3 etx 4 eot 5 enq 6 ack 7 bel */
0, 0, 0, 0, 0, 0, 0, 0,
/* 8 bs 9 ht 10 nl 11 vt 12 np 13 cr 14 so 15 si */
@@ -600,7 +600,7 @@ size_t http_parser_execute (http_parser *parser,
if (ch == ' ' && matcher[index] == '\0') {
state = s_req_spaces_before_url;
} else if (ch == matcher[index]) {
- ; // nada
+ ; /* nada */
} else if (parser->method == HTTP_CONNECT) {
if (index == 1 && ch == 'H') {
parser->method = HTTP_CHECKOUT;
@@ -772,7 +772,7 @@ size_t http_parser_execute (http_parser *parser,
switch (ch) {
case '?':
- break; // XXX ignore extra '?' ... is this right?
+ break; /* XXX ignore extra '?' ... is this right? */
case ' ':
CALLBACK(url);
state = s_req_http_start;
@@ -802,7 +802,7 @@ size_t http_parser_execute (http_parser *parser,
switch (ch) {
case '?':
- // allow extra '?' in query string
+ /* allow extra '?' in query string */
break;
case ' ':
CALLBACK(url);
@@ -1264,6 +1264,7 @@ size_t http_parser_execute (http_parser *parser,
break;
case h_content_length:
+ if (ch == ' ') break;
if (ch < '0' || ch > '9') goto error;
parser->content_length *= 10;
parser->content_length += ch - '0';
@@ -1376,7 +1377,7 @@ size_t http_parser_execute (http_parser *parser,
}
}
- // Exit, the rest of the connect is in a different protocol.
+ /* Exit, the rest of the connect is in a different protocol. */
if (parser->upgrade) {
CALLBACK2(message_complete);
return (p - data);
@@ -1437,7 +1438,7 @@ size_t http_parser_execute (http_parser *parser,
{
assert(parser->flags & F_CHUNKED);
- c = unhex[(int)ch];
+ c = unhex[(unsigned char)ch];
if (c == -1) goto error;
parser->content_length = c;
state = s_chunk_size;
@@ -1453,7 +1454,7 @@ size_t http_parser_execute (http_parser *parser,
break;
}
- c = unhex[(int)ch];
+ c = unhex[(unsigned char)ch];
if (c == -1) {
if (ch == ';' || ch == ' ') {
@@ -1545,6 +1546,7 @@ size_t http_parser_execute (http_parser *parser,
return len;
error:
+ parser->state = s_dead;
return (p - data);
}
diff --git a/deps/http_parser/http_parser.h b/deps/http_parser/http_parser.h
index 2e395a24e9..793089a67d 100644
--- a/deps/http_parser/http_parser.h
+++ b/deps/http_parser/http_parser.h
@@ -100,14 +100,13 @@ enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
struct http_parser {
/** PRIVATE **/
- unsigned char type;
+ unsigned char type : 2;
+ unsigned char flags : 6;
unsigned char state;
unsigned char header_state;
unsigned char index;
- char flags;
-
- uint64_t nread;
+ uint32_t nread;
int64_t content_length;
/** READ-ONLY **/