Merge R_2_5
[m6w6/ext-http] / php_http_message.c
index d61644ce3de734b2c7bda3598f5d91bf643b5e7f..e6cdbc8f143782b56784239e6ebde8e16b552477 100644 (file)
@@ -86,7 +86,7 @@ php_http_message_t *php_http_message_init_env(php_http_message_t *message, php_h
                        php_http_env_get_response_headers(&message->hdrs);
                        if (php_output_get_level()) {
                                if (php_output_get_status() & PHP_OUTPUT_SENT) {
-                                       php_error_docref(NULL, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(TSRMLS_C), php_output_get_start_lineno(TSRMLS_C));
+                                       php_error_docref(NULL, E_WARNING, "Could not fetch response body, output has already been sent at %s:%d", php_output_get_start_filename(), php_output_get_start_lineno());
                                        goto error;
                                } else if (SUCCESS != php_output_get_contents(&tval)) {
                                        php_error_docref(NULL, E_WARNING, "Could not fetch response body");
@@ -776,10 +776,11 @@ ZEND_RESULT_CODE php_http_message_object_set_body(php_http_message_object_t *msg
        }
        if (msg_obj->message) {
                php_http_message_body_free(&msg_obj->message->body);
-               msg_obj->message->body = php_http_message_body_init(&body_obj->body, NULL);
+               msg_obj->message->body = body_obj->body;
        } else {
-               msg_obj->message = php_http_message_init(NULL, 0, php_http_message_body_init(&body_obj->body, NULL));
+               msg_obj->message = php_http_message_init(NULL, 0, body_obj->body);
        }
+       php_http_message_body_addref(body_obj->body);
        msg_obj->body = body_obj;
 
        return SUCCESS;
@@ -817,7 +818,7 @@ php_http_message_object_t *php_http_message_object_new_ex(zend_class_entry *ce,
        return o;
 }
 
-zend_object *php_http_message_object_clone(zval *this_ptr TSRMLS_DC)
+zend_object *php_http_message_object_clone(zval *this_ptr)
 {
        php_http_message_object_t *new_obj = NULL;
        php_http_message_object_t *old_obj = PHP_HTTP_OBJ(NULL, this_ptr);
@@ -877,6 +878,8 @@ static zval *php_http_message_object_read_prop(zval *object, zval *member, int t
                        zval_ptr_dtor(return_value);
                        ZVAL_COPY_VALUE(return_value, tmp);
                }
+               zend_string_release(member_name);
+               return return_value;
        } else {
                php_property_proxy_t *proxy;
                php_property_proxy_object_t *proxy_obj;
@@ -885,12 +888,9 @@ static zval *php_http_message_object_read_prop(zval *object, zval *member, int t
                proxy_obj = php_property_proxy_object_new_ex(NULL, proxy);
 
                ZVAL_OBJ(tmp, &proxy_obj->zo);
+               zend_string_release(member_name);
                return tmp;
        }
-
-       zend_string_release(member_name);
-
-       return return_value;
 }
 
 static void php_http_message_object_write_prop(zval *object, zval *member, zval *value, void **cache_slot)
@@ -1408,7 +1408,7 @@ static PHP_METHOD(HttpMessage, setResponseCode)
        zend_bool strict = 1;
        php_http_message_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|b", &code, &strict), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "l|b", &code, &strict), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
        PHP_HTTP_MESSAGE_OBJECT_INIT(obj);
@@ -1459,7 +1459,7 @@ static PHP_METHOD(HttpMessage, setResponseStatus)
        size_t status_len;
        php_http_message_object_t *obj;
 
-       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &status, &status_len), invalid_arg, return);
+       php_http_expect(SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &status, &status_len), invalid_arg, return);
 
        obj = PHP_HTTP_OBJ(NULL, getThis());
 
@@ -1575,10 +1575,10 @@ static PHP_METHOD(HttpMessage, setRequestUrl)
        url = php_http_url_from_zval(zurl, ~0);
        zend_restore_error_handling(&zeh);
 
-       if (php_http_url_is_empty(url)) {
+       if (url && php_http_url_is_empty(url)) {
                php_http_url_free(&url);
                php_http_throw(invalid_arg, "Cannot set http\\Message's request url to an empty string", NULL);
-       } else {
+       } else if (url) {
                PTR_SET(obj->message->http.info.request.url, url);
        }
 
@@ -1709,7 +1709,7 @@ static PHP_METHOD(HttpMessage, unserialize)
                        obj->message = msg;
                } else {
                        obj->message = php_http_message_init(NULL, 0, NULL);
-                       php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not unserialize http\\Message");
+                       php_error_docref(NULL, E_ERROR, "Could not unserialize http\\Message");
                }
        }
 }
@@ -1831,7 +1831,7 @@ static PHP_METHOD(HttpMessage, count)
 {
        zend_long count_mode = -1;
 
-       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &count_mode)) {
+       if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &count_mode)) {
                php_http_message_object_t *obj = PHP_HTTP_OBJ(NULL, getThis());
 
                PHP_HTTP_MESSAGE_OBJECT_INIT(obj);