Skip to content

Commit a8f8732

Browse files
Merge branch '5.4' into 6.0
* 5.4: [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 f2461a7 + fab8479 commit a8f8732

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

AmpHttpClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ 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;
47+
4648
private $multi;
4749

4850
/**

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 $multi;
4143

4244
/**

Tests/HttpClientTestCase.php

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

0 commit comments

Comments
 (0)