Fixed bug #68149 (duplicate content-length with libcurl < 7.23)
authorMichael Wallner <mike@php.net>
Thu, 6 Nov 2014 12:06:45 +0000 (13:06 +0100)
committerMichael Wallner <mike@php.net>
Thu, 6 Nov 2014 12:06:45 +0000 (13:06 +0100)
package.xml
php_http_client_curl.c

index eddca2610775b6d6152661174a1d3ac50913c228..196688852e0a30e929d442d06609b3d98e213447 100644 (file)
@@ -49,6 +49,7 @@ v2: http://dev.iworks.at/ext-http/lcov/ext/http/
  <license>BSD, revised</license>
  <notes><![CDATA[
 * Fixed bug #68353 (QsoSSL support removed in libcurl 7.39)
  <license>BSD, revised</license>
  <notes><![CDATA[
 * Fixed bug #68353 (QsoSSL support removed in libcurl 7.39)
+* Fixed bug #68149 (duplicate content-length with libcurl < 7.23)
 ]]></notes>
  <contents>
   <dir name="/">
 ]]></notes>
  <contents>
   <dir name="/">
index 48deae38df4c00772ce77a85b13e9030018289e7..4573df7e1ce7c1c76a1f04ce53b69f751898b3db 100644 (file)
@@ -1636,15 +1636,25 @@ static STATUS php_http_client_curl_handler_prepare(php_http_client_curl_handler_
        php_http_message_update_headers(msg);
        if (zend_hash_num_elements(&msg->hdrs)) {
                php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0);
        php_http_message_update_headers(msg);
        if (zend_hash_num_elements(&msg->hdrs)) {
                php_http_array_hashkey_t header_key = php_http_array_hashkey_init(0);
-               zval **header_val;
+               zval **header_val, *header_cpy;
                HashPosition pos;
                php_http_buffer_t header;
                HashPosition pos;
                php_http_buffer_t header;
+#if !PHP_HTTP_CURL_VERSION(7,23,0)
+               zval **ct = NULL;
+
+               zend_hash_find(&msg->hdrs, ZEND_STRS("Content-Length"), (void *) &ct);
+#endif
 
                php_http_buffer_init(&header);
                FOREACH_HASH_KEYVAL(pos, &msg->hdrs, header_key, header_val) {
                        if (header_key.type == HASH_KEY_IS_STRING) {
 
                php_http_buffer_init(&header);
                FOREACH_HASH_KEYVAL(pos, &msg->hdrs, header_key, header_val) {
                        if (header_key.type == HASH_KEY_IS_STRING) {
-                               zval *header_cpy = php_http_ztyp(IS_STRING, *header_val);
-
+#if !PHP_HTTP_CURL_VERSION(7,23,0)
+                               /* avoid duplicate content-length header */
+                               if (ct && *ct == *header_val) {
+                                       continue;
+                               }
+#endif
+                               header_cpy = php_http_ztyp(IS_STRING, *header_val);
                                php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy));
                                php_http_buffer_fix(&header);
                                curl->options.headers = curl_slist_append(curl->options.headers, header.data);
                                php_http_buffer_appendf(&header, "%s: %s", header_key.str, Z_STRVAL_P(header_cpy));
                                php_http_buffer_fix(&header);
                                curl->options.headers = curl_slist_append(curl->options.headers, header.data);