diff --git a/src/Client/Adapter/Curl.php b/src/Client/Adapter/Curl.php index c5a0c953..e4bdcdd9 100644 --- a/src/Client/Adapter/Curl.php +++ b/src/Client/Adapter/Curl.php @@ -387,6 +387,9 @@ public function write($method, $uri, $httpVersion = 1.1, $headers = [], $body = curl_setopt($this->curl, CURLOPT_HTTP_VERSION, $curlHttp); curl_setopt($this->curl, $curlMethod, $curlValue); + // Set the CURLOPT_NOBODY flag for HEAD HTTP method + curl_setopt($this->curl, CURLOPT_NOBODY, $curlMethod === CURLOPT_CUSTOMREQUEST && $curlValue === 'HEAD'); + // Set the CURLINFO_HEADER_OUT flag so that we can retrieve the full request string later curl_setopt($this->curl, CURLINFO_HEADER_OUT, true); diff --git a/test/Client/CurlTest.php b/test/Client/CurlTest.php index 482d5ada..6507288c 100644 --- a/test/Client/CurlTest.php +++ b/test/Client/CurlTest.php @@ -381,6 +381,16 @@ public function testHeadRequest() $this->assertEquals('', $this->client->getResponse()->getBody()); } + public function testHeadRequestWithContentLengthHeader() + { + $this->client->setUri($this->baseuri . 'testHeadMethod.php'); + $adapter = new Adapter\Curl(); + $this->client->setAdapter($adapter); + $this->client->setMethod('HEAD'); + $this->client->send(); + $this->assertEquals('', $this->client->getResponse()->getBody()); + } + public function testAuthorizeHeader() { // We just need someone to talk to diff --git a/test/Client/_files/testHeadMethod.php b/test/Client/_files/testHeadMethod.php new file mode 100644 index 00000000..a7a5155c --- /dev/null +++ b/test/Client/_files/testHeadMethod.php @@ -0,0 +1,12 @@ +