Skip to content

Commit

Permalink
Merge cac1c35 into 998042a
Browse files Browse the repository at this point in the history
  • Loading branch information
karneds committed Dec 28, 2020
2 parents 998042a + cac1c35 commit 80654a2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Client/Adapter/Curl.php
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/Client/CurlTest.php
Expand Up @@ -365,7 +365,7 @@ public function testGetCurlHandle()
*/
public function testHeadRequest()
{
$this->client->setUri($this->baseuri . 'testRawPostData.php');
$this->client->setUri($this->baseuri . 'testHeadMethod.php');
$adapter = new Adapter\Curl();
$this->client->setAdapter($adapter);
$this->client->setMethod('HEAD');
Expand Down
12 changes: 12 additions & 0 deletions test/Client/_files/testHeadMethod.php
@@ -0,0 +1,12 @@
<?php

/**
* @see https://github.com/laminas/laminas-http for the canonical source repository
* @copyright https://github.com/laminas/laminas-http/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-http/blob/master/LICENSE.md New BSD License
*/


$clength = filesize(__FILE__);

header(sprintf('Content-length: %s', $clength));

0 comments on commit 80654a2

Please sign in to comment.