Skip to content

Commit 9333763

Browse files
committed
set CURLOPT_NOBODY for HEAD requests
1 parent b867a2a commit 9333763

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/Psr18/Client.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ protected function initRequest(RequestInterface $request, ResponseHeaderParser $
132132

133133
$ch->setopt(CURLOPT_HEADERFUNCTION, $headerParser->getClosure());
134134
$ch->setopt(CURLOPT_CUSTOMREQUEST, $request->getMethod());
135+
if ($request->getMethod() === "HEAD") {
136+
$ch->setopt(CURLOPT_NOBODY, true);
137+
}
135138

136139
$this->setHeaders($request, $ch);
137140

tests/HttpClientTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function testHead(): void
8686
$this->assertEquals(200, $response->getStatusCode());
8787
$this->assertEquals("TEST", $response->getReasonPhrase());
8888
$this->assertEquals("HEAD", $this->curlHandle->getOption(CURLOPT_CUSTOMREQUEST));
89+
$this->assertTrue($this->curlHandle->getOption(CURLOPT_NOBODY));
8990
}
9091

9192
public function testCustom(): void

0 commit comments

Comments
 (0)