http_parser_init does not clear status_code

v0.10
Ivo Raisr 13 years ago committed by Ben Noordhuis
parent 7f89b91314
commit 2a2f99f9cd

@ -26,6 +26,7 @@
#include <stddef.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#ifndef MIN
@ -1849,12 +1850,11 @@ const char * http_method_str (enum http_method m)
void
http_parser_init (http_parser *parser, enum http_parser_type t)
{
void *data = parser->data; /* preserve application data */
memset(parser, 0, sizeof(*parser));
parser->data = data;
parser->type = t;
parser->state = (t == HTTP_REQUEST ? s_start_req : (t == HTTP_RESPONSE ? s_start_res : s_start_req_or_res));
parser->nread = 0;
parser->upgrade = 0;
parser->flags = 0;
parser->method = 0;
parser->http_errno = HPE_OK;
}

@ -1835,6 +1835,18 @@ print_error (const char *raw, size_t error_location)
fprintf(stderr, "^\n\nerror location: %u\n", (unsigned int)error_location);
}
void
test_preserve_data (void)
{
char my_data[] = "application-specific data";
http_parser parser;
parser.data = my_data;
http_parser_init(&parser, HTTP_REQUEST);
if (parser.data != my_data) {
printf("\n*** parser.data not preserved accross http_parser_init ***\n\n");
exit(1);
}
}
void
test_message (const struct message *message)
@ -2295,6 +2307,9 @@ main (void)
for (request_count = 0; requests[request_count].name; request_count++);
for (response_count = 0; responses[response_count].name; response_count++);
//// API
test_preserve_data();
//// OVERFLOW CONDITIONS
test_header_overflow_error(HTTP_REQUEST);

Loading…
Cancel
Save