From: Michael Wallner Date: Mon, 19 Jan 2015 13:30:54 +0000 (+0100) Subject: fix message parser content length X-Git-Tag: RELEASE_3_0_0_RC1~87 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=49c4716aa5a97b2ae94491e74f5ff5c13c0ddee3;p=m6w6%2Fext-http fix message parser content length --- diff --git a/php_http_header_parser.c b/php_http_header_parser.c index 65c0b24..e14b443 100644 --- a/php_http_header_parser.c +++ b/php_http_header_parser.c @@ -94,8 +94,11 @@ php_http_header_parser_state_t php_http_header_parser_parse(php_http_header_pars { while (buffer->used || !php_http_header_parser_states[php_http_header_parser_state_is(parser)].need_data) { #if 0 - const char *state[] = {"START", "KEY", "VALUE", "HEADER_DONE", "DONE"}; - fprintf(stderr, "#HP: %s (avail:%zu, num:%d)\n", php_http_header_parser_state_is(parser) < 0 ? "FAILURE" : state[php_http_header_parser_state_is(parser)], buffer->used, headers?zend_hash_num_elements(headers):0); + const char *state[] = {"START", "KEY", "VALUE", "VALUE_EX", "HEADER_DONE", "DONE"}; + int num_headers = headers ? zend_hash_num_elements(headers) : 0; + fprintf(stderr, "#HP: (%d) %s (avail:%zu, num:%d)\n", php_http_header_parser_state_is(parser), + php_http_header_parser_state_is(parser) < 0 ? "FAILURE" : state[php_http_header_parser_state_is(parser)], + buffer->used, num_headers); _dpf(0, buffer->data, buffer->used); #endif switch (php_http_header_parser_state_pop(parser)) { diff --git a/php_http_message.c b/php_http_message.c index ff228c7..3fddf79 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -20,7 +20,7 @@ zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable /* advance message */ if (!old || old->type || zend_hash_num_elements(&old->hdrs)) { - (*message) = php_http_message_init(NULL, 0, NULL TSRMLS_CC); + (*message) = php_http_message_init(NULL, 0, NULL); (*message)->parent = old; if (headers) { (*headers) = &((*message)->hdrs); diff --git a/php_http_message_parser.c b/php_http_message_parser.c index eec4433..e4eab11 100644 --- a/php_http_message_parser.c +++ b/php_http_message_parser.c @@ -256,7 +256,7 @@ php_http_message_parser_state_t php_http_message_parser_parse(php_http_message_p } if ((h_cl = php_http_message_header(*message, ZEND_STRL("Content-Length")))) { Z_TRY_ADDREF_P(h_cl); - zend_hash_str_update(&(*message)->hdrs, "X-Original-Content-Length", lenof("X-Original-Content-Length"), h_cl); + h_cl = zend_hash_str_update(&(*message)->hdrs, "X-Original-Content-Length", lenof("X-Original-Content-Length"), h_cl); } if ((h_cr = php_http_message_header(*message, ZEND_STRL("Content-Range")))) { Z_TRY_ADDREF_P(h_cr);