From 180fca20064e7c2e1166117732da7e2b1ee31730 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 8 Sep 2015 10:13:29 +0200 Subject: [PATCH] fixed HEAD regression always warning about a partial file transfer --- package.xml | 1 + php_http_client_curl.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.xml b/package.xml index e04ee2f..cdec164 100644 --- a/package.xml +++ b/package.xml @@ -46,6 +46,7 @@ http://dev.iworks.at/ext-http/lcov/ext/http/ BSD, revised = 7.42) ]]> diff --git a/php_http_client_curl.c b/php_http_client_curl.c index 763525f..fed92fc 100644 --- a/php_http_client_curl.c +++ b/php_http_client_curl.c @@ -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 { -- 2.30.2