Skip to content

Commit 6f84e44

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: [Console] Fix division by 0 error [ErrorHandler] Fix error message with PHP 8.5 Add an experimental CI job for PHP 8.5 [HttpClient] Always set CURLOPT_CUSTOMREQUEST to the correct HTTP method in CurlHttpClient evaluate access flags for properties with asymmetric visibility [Mime] Fix wrong PHPDoc in `FormDataPart` constructor
2 parents f4459f8 + f4f6d81 commit 6f84e44

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

CurlHttpClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,12 @@ public function request(string $method, string $url, array $options = []): Respo
197197
$curlopts[\CURLOPT_RESOLVE] = $resolve;
198198
}
199199

200+
$curlopts[\CURLOPT_CUSTOMREQUEST] = $method;
200201
if ('POST' === $method) {
201202
// Use CURLOPT_POST to have browser-like POST-to-GET redirects for 301, 302 and 303
202203
$curlopts[\CURLOPT_POST] = true;
203204
} elseif ('HEAD' === $method) {
204205
$curlopts[\CURLOPT_NOBODY] = true;
205-
} else {
206-
$curlopts[\CURLOPT_CUSTOMREQUEST] = $method;
207206
}
208207

209208
if ('\\' !== \DIRECTORY_SEPARATOR && $options['timeout'] < 1) {

Tests/HttpClientTestCase.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,4 +656,26 @@ public function testDefaultContentType()
656656

657657
$this->assertSame(['abc' => 'def', 'content-type' => 'application/json', 'REQUEST_METHOD' => 'POST'], $response->toArray());
658658
}
659+
660+
public function testHeadRequestWithClosureBody()
661+
{
662+
$p = TestHttpServer::start(8067);
663+
664+
try {
665+
$client = $this->getHttpClient(__FUNCTION__);
666+
667+
$response = $client->request('HEAD', 'http://localhost:8057/head', [
668+
'body' => fn () => '',
669+
]);
670+
$headers = $response->getHeaders();
671+
} finally {
672+
$p->stop();
673+
}
674+
675+
$this->assertArrayHasKey('x-request-vars', $headers);
676+
677+
$vars = json_decode($headers['x-request-vars'][0], true);
678+
$this->assertIsArray($vars);
679+
$this->assertSame('HEAD', $vars['REQUEST_METHOD']);
680+
}
659681
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": ">=8.2",
2626
"psr/log": "^1|^2|^3",
2727
"symfony/deprecation-contracts": "^2.5|^3",
28-
"symfony/http-client-contracts": "~3.4.3|^3.5.1",
28+
"symfony/http-client-contracts": "~3.4.4|^3.5.2",
2929
"symfony/service-contracts": "^2.5|^3"
3030
},
3131
"require-dev": {

0 commit comments

Comments
 (0)