- win32 build now has libcurl v7.16.0
[m6w6/ext-http] / http_message_object.c
index c984e960fa00a34e2da1a78f282c55784d1e8443..5624e2172a744be2b9dd40819d1d15705d707902 100644 (file)
@@ -637,13 +637,13 @@ static HashTable *_http_message_object_get_props(zval *object TSRMLS_DC)
                case HTTP_MSG_REQUEST:
                        ASSOC_PROP(array, long, "responseCode", 0);
                        ASSOC_STRINGL(array, "responseStatus", "", 0);
-                       ASSOC_STRING(array, "requestMethod", msg->http.info.request.method?msg->http.info.request.method:"");
-                       ASSOC_STRING(array, "requestUrl", msg->http.info.request.url?msg->http.info.request.url:"");
+                       ASSOC_STRING(array, "requestMethod", STR_PTR(msg->http.info.request.method));
+                       ASSOC_STRING(array, "requestUrl", STR_PTR(msg->http.info.request.url));
                        break;
 
                case HTTP_MSG_RESPONSE:
                        ASSOC_PROP(array, long, "responseCode", msg->http.info.response.code);
-                       ASSOC_STRING(array, "responseStatus", msg->http.info.response.status?msg->http.info.response.status:"");
+                       ASSOC_STRING(array, "responseStatus", STR_PTR(msg->http.info.response.status));
                        ASSOC_STRINGL(array, "requestMethod", "", 0);
                        ASSOC_STRINGL(array, "requestUrl", "", 0);
                        break;
@@ -809,8 +809,8 @@ PHP_METHOD(HttpMessage, getHeader)
        }
        
        nice_header = pretty_key(estrndup(orig_header, header_len), header_len, 1, 1);
-       if ((header = http_message_header_ex(obj->message, nice_header, header_len + 1))) {
-               RETVAL_ZVAL(header, 1, 0);
+       if ((header = http_message_header_ex(obj->message, nice_header, header_len + 1, 0))) {
+               RETVAL_ZVAL(header, 1, 1);
        }
        efree(nice_header);
 }
@@ -846,16 +846,18 @@ PHP_METHOD(HttpMessage, getHeaders)
  */
 PHP_METHOD(HttpMessage, setHeaders)
 {
-       zval *new_headers, old_headers;
+       zval *new_headers = NULL, old_headers;
        getObject(http_message_object, obj);
 
-       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &new_headers)) {
+       if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/!", &new_headers)) {
                return;
        }
 
        zend_hash_clean(&obj->message->hdrs);
-       INIT_ZARR(old_headers, &obj->message->hdrs);
-       array_copy(new_headers, &old_headers);
+       if (new_headers) {
+               INIT_ZARR(old_headers, &obj->message->hdrs);
+               array_copy(new_headers, &old_headers);
+       }
 }
 /* }}} */
 
@@ -1304,6 +1306,7 @@ PHP_METHOD(HttpMessage, toMessageTypeObject)
                                
                                memset(&hurl, 0, sizeof(php_url));
                                hurl.host = host ? Z_STRVAL_P(host) : NULL;
+                               zval_ptr_dtor(&host);
                                http_build_url(HTTP_URL_REPLACE, purl, &hurl, NULL, &url, NULL);
                                php_url_free(purl);
                                add_assoc_string(array, "url", url, 0);