Skip to content

Commit 768fb01

Browse files
Merge branch '6.0' into 6.1
* 6.0: [HttpClient] fix [HttpClient] Handle requests with null body [WebProfilerBundle] Log section minor fixes (missing "notice" filter, log priority, accessibility) Fix link not present
2 parents 98d6f59 + a8f8732 commit 768fb01

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

AmpHttpClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ final class AmpHttpClient implements HttpClientInterface, LoggerAwareInterface,
4343
use LoggerAwareTrait;
4444

4545
private array $defaultOptions = self::OPTIONS_DEFAULTS;
46+
private static array $emptyDefaults = self::OPTIONS_DEFAULTS;
4647
private AmpClientState $multi;
4748

4849
/**

CurlHttpClient.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface,
4343
'curl' => [], // A list of extra curl options indexed by their corresponding CURLOPT_*
4444
],
4545
];
46+
private static array $emptyDefaults = self::OPTIONS_DEFAULTS + ['auth_ntlm' => null];
4647

4748
private ?LoggerInterface $logger = null;
4849

HttpClientTrait.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
201201

202202
$options += $defaultOptions;
203203

204+
foreach (self::$emptyDefaults ?? [] as $k => $v) {
205+
if (!isset($options[$k])) {
206+
$options[$k] = $v;
207+
}
208+
}
209+
204210
if (isset($defaultOptions['extra'])) {
205211
$options['extra'] += $defaultOptions['extra'];
206212
}
@@ -233,9 +239,9 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
233239

234240
$alternatives = [];
235241

236-
foreach ($defaultOptions as $key => $v) {
237-
if (levenshtein($name, $key) <= \strlen($name) / 3 || str_contains($key, $name)) {
238-
$alternatives[] = $key;
242+
foreach ($defaultOptions as $k => $v) {
243+
if (levenshtein($name, $k) <= \strlen($name) / 3 || str_contains($k, $name)) {
244+
$alternatives[] = $k;
239245
}
240246
}
241247

NativeHttpClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ final class NativeHttpClient implements HttpClientInterface, LoggerAwareInterfac
3737
use LoggerAwareTrait;
3838

3939
private array $defaultOptions = self::OPTIONS_DEFAULTS;
40+
private static array $emptyDefaults = self::OPTIONS_DEFAULTS;
41+
4042
private NativeClientState $multi;
4143

4244
/**

Tests/HttpClientTestCase.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,4 +395,15 @@ public function testNegativeTimeout()
395395
'timeout' => -1,
396396
])->getStatusCode());
397397
}
398+
399+
public function testNullBody()
400+
{
401+
$httpClient = $this->getHttpClient(__FUNCTION__);
402+
403+
$httpClient->request('POST', 'http://localhost:8057/post', [
404+
'body' => null,
405+
]);
406+
407+
$this->expectNotToPerformAssertions();
408+
}
398409
}

0 commit comments

Comments
 (0)