fix message parser content length
authorMichael Wallner <mike@php.net>
Mon, 19 Jan 2015 13:30:54 +0000 (14:30 +0100)
committerMichael Wallner <mike@php.net>
Mon, 19 Jan 2015 13:30:54 +0000 (14:30 +0100)
php_http_header_parser.c
php_http_message.c
php_http_message_parser.c

index 65c0b24296bd8f6ddda1dcf2a23b87019d873b23..e14b44333b1efe44b23b6f05fe2ba65f14bd3d11 100644 (file)
@@ -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)) {
index ff228c77f6520d5e1d8f3681576de051ef813b66..3fddf79701dc6a152d3647f84ac32d28fb957af3 100644 (file)
@@ -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);
index eec4433fd2a606e4ec2688bc4c7289a2aeb4ff39..e4eab11f94addea20d0f8ba1a69812ee641036b5 100644 (file)
@@ -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);