Fix missing IS_BOOL
[m6w6/ext-http] / php_http_message.c
index 4109202226caae9abb31ac5340c5e69800899ea3..3d3822cfeeb8326e455e5aae29d8d1afa93e8b38 100644 (file)
@@ -275,6 +275,8 @@ void php_http_message_update_headers(php_http_message_t *msg)
 
        if (php_http_message_body_stream(msg->body)->readfilters.head) {
                /* if a read stream filter is attached to the body the caller must also care for the headers */
+       } else if (php_http_message_header(msg, ZEND_STRL("Content-Range"))) {
+               /* don't mess around with a Content-Range message */
        } else if ((size = php_http_message_body_size(msg->body))) {
                ZVAL_LONG(&h, size);
                zend_hash_str_update(&msg->hdrs, "Content-Length", lenof("Content-Length"), &h);
@@ -299,6 +301,7 @@ void php_http_message_update_headers(php_http_message_t *msg)
                }
        } else if ((cl = php_http_message_header_string(msg, ZEND_STRL("Content-Length")))) {
                if (!zend_string_equals_literal(cl, "0")) {
+                       /* body->size == 0, so get rid of old Content-Length */
                        zend_hash_str_del(&msg->hdrs, ZEND_STRL("Content-Length"));
                }
                zend_string_release(cl);
@@ -604,9 +607,8 @@ static void php_http_message_object_prophandler_set_headers(php_http_message_obj
 
        if (Z_TYPE_P(value) != IS_ARRAY && Z_TYPE_P(value) != IS_OBJECT) {
                convert_to_array_ex(value);
-       } else {
-               headers = HASH_OF(value);
        }
+       headers = HASH_OF(value);
 
        zend_hash_clean(&obj->message->hdrs);
        array_copy(headers, &obj->message->hdrs);
@@ -688,7 +690,7 @@ void php_http_message_object_reverse(zval *zmsg, zval *return_value)
 
                /* add ref, because we previously have not been a parent message */
                Z_ADDREF_P(zmsg);
-               RETVAL_OBJ(&objects[last]->zo);
+               RETVAL_OBJECT(&objects[last]->zo, 1);
 
                efree(objects);
        } else {
@@ -798,7 +800,7 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce,
 {
        php_http_message_object_t *o;
 
-       o = ecalloc(1, sizeof(php_http_message_object_t) + (ce->default_properties_count - 1) * sizeof(zval));
+       o = ecalloc(1, sizeof(*o) + zend_object_properties_size(ce));
        zend_object_std_init(&o->zo, ce);
        object_properties_init(&o->zo, ce);
 
@@ -1107,15 +1109,18 @@ static PHP_METHOD(HttpMessage, getHeader)
 
                if ((header = php_http_message_header(obj->message, header_str, header_len))) {
                        if (!header_ce) {
-                               RETURN_ZVAL(header, 1, 1);
+                               RETURN_ZVAL_FAST(header);
                        } else if (instanceof_function(header_ce, php_http_header_class_entry)) {
+                               php_http_object_method_t cb;
                                zval argv[2];
 
                                ZVAL_STRINGL(&argv[0], header_str, header_len);
                                ZVAL_COPY(&argv[1], header);
 
                                object_init_ex(return_value, header_ce);
-                               php_http_method_call(return_value, ZEND_STRL("__construct"), 2, argv, NULL);
+                               php_http_object_method_init(&cb, return_value, ZEND_STRL("__construct"));
+                               php_http_object_method_call(&cb, return_value, NULL, 2, argv);
+                               php_http_object_method_dtor(&cb);
 
                                zval_ptr_dtor(&argv[0]);
                                zval_ptr_dtor(&argv[1]);