fixed HEAD regression always warning about a partial file transfer
authorMichael Wallner <mike@php.net>
Tue, 8 Sep 2015 08:13:29 +0000 (10:13 +0200)
committerMichael Wallner <mike@php.net>
Tue, 8 Sep 2015 08:13:29 +0000 (10:13 +0200)
package.xml
php_http_client_curl.c

index e04ee2f65568bb0a8b9664a91b7be529c2fa0e54..cdec164e40a2fd5006ba743e403d9c3773f5a3e8 100644 (file)
@@ -46,6 +46,7 @@ http://dev.iworks.at/ext-http/lcov/ext/http/
  </stability>
  <license>BSD, revised</license>
  <notes><![CDATA[
+* Fixed regression with HEAD requests always warning about a partial file transfer
 + Added "path_as_is" request option (libcurl >= 7.42)
 ]]></notes>
  <contents>
index 763525f968fc3f201d86d0e2a0bb3ea98c1d1b5c..fed92fc078f2c4a95649c53901f5393c8c05483a 100644 (file)
@@ -2008,9 +2008,14 @@ static ZEND_RESULT_CODE php_http_client_curl_handler_prepare(php_http_client_cur
         * See also https://tools.ietf.org/html/rfc7231#section-5.1.1
         */
        if (PHP_HTTP_INFO(msg).request.method) {
-               if (!strcasecmp("PUT", PHP_HTTP_INFO(msg).request.method)) {
+               switch(php_http_select_str(PHP_HTTP_INFO(msg).request.method, 2, "HEAD", "PUT")) {
+               case 0:
+                       curl_easy_setopt(curl->handle, CURLOPT_NOBODY, 1L);
+                       break;
+               case 1:
                        curl_easy_setopt(curl->handle, CURLOPT_UPLOAD, 1L);
-               } else {
+                       break;
+               default:
                        curl_easy_setopt(curl->handle, CURLOPT_CUSTOMREQUEST, PHP_HTTP_INFO(msg).request.method);
                }
        } else {