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
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jul 13, 2009
1 parent 2819e3b commit 116069f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion deps/http_parser/http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1

#define MAX_FIELD_SIZE 80*1024

#define REMAINING (pe - p)
#define REMAINING (unsigned long)(pe - p)
#define CALLBACK(FOR) \
do { \
if (parser->FOR##_mark) { \
Expand Down
2 changes: 1 addition & 1 deletion deps/http_parser/http_parser.rl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static int unhex[] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1

#define MAX_FIELD_SIZE 80*1024

#define REMAINING (pe - p)
#define REMAINING (unsigned long)(pe - p)
#define CALLBACK(FOR) \
do { \
if (parser->FOR##_mark) { \
Expand Down
29 changes: 19 additions & 10 deletions deps/http_parser/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,36 +358,41 @@ const struct message responses[] =
};

int
request_path_cb (http_parser *_, const char *p, size_t len)
request_path_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
strncat(messages[num_messages].request_path, p, len);
return 0;
}

int
request_uri_cb (http_parser *_, const char *p, size_t len)
request_uri_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
strncat(messages[num_messages].request_uri, p, len);
return 0;
}

int
query_string_cb (http_parser *_, const char *p, size_t len)
query_string_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
strncat(messages[num_messages].query_string, p, len);
return 0;
}

int
fragment_cb (http_parser *_, const char *p, size_t len)
fragment_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
strncat(messages[num_messages].fragment, p, len);
return 0;
}

int
header_field_cb (http_parser *_, const char *p, size_t len)
header_field_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
struct message *m = &messages[num_messages];

if (m->last_header_element != FIELD)
Expand All @@ -401,8 +406,9 @@ header_field_cb (http_parser *_, const char *p, size_t len)
}

int
header_value_cb (http_parser *_, const char *p, size_t len)
header_value_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
struct message *m = &messages[num_messages];

strncat(m->headers[m->num_headers-1][1], p, len);
Expand All @@ -413,8 +419,9 @@ header_value_cb (http_parser *_, const char *p, size_t len)
}

int
body_cb (http_parser *_, const char *p, size_t len)
body_cb (http_parser *parser, const char *p, size_t len)
{
assert(parser);
strncat(messages[num_messages].body, p, len);
// printf("body_cb: '%s'\n", requests[num_messages].body);
return 0;
Expand All @@ -433,15 +440,17 @@ message_complete_cb (http_parser *parser)
}

int
message_begin_cb (http_parser *_)
message_begin_cb (http_parser *parser)
{
assert(parser);
messages[num_messages].message_begin_cb_called = TRUE;
return 0;
}

int
headers_complete_cb (http_parser *_)
headers_complete_cb (http_parser *parser)
{
assert(parser);
messages[num_messages].headers_complete_cb_called = TRUE;
return 0;
}
Expand Down Expand Up @@ -643,7 +652,7 @@ test_scan (const struct message *r1, const struct message *r2, const struct mess
message_eq(2, r3);
}
}
printf("\b\b\b\b100%\n");
puts("\b\b\b\b100%");
}

int
Expand Down

0 comments on commit 116069f

Please sign in to comment.