Skip to content

Commit fab8479

Browse files
Merge branch '4.4' into 5.4
* 4.4: [HttpClient] fix
2 parents 42255a4 + a6b1a66 commit fab8479

File tree

6 files changed

+15
-27
lines changed

6 files changed

+15
-27
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 $defaultOptions = self::OPTIONS_DEFAULTS;
46+
private static $emptyDefaults = self::OPTIONS_DEFAULTS;
4647

4748
/** @var AmpClientState */
4849
private $multi;

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 $emptyDefaults = self::OPTIONS_DEFAULTS + ['auth_ntlm' => null];
4647

4748
/**
4849
* @var LoggerInterface|null

HttpClientTrait.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
trait HttpClientTrait
2525
{
2626
private static $CHUNK_SIZE = 16372;
27-
private static $emptyDefaults;
2827

2928
/**
3029
* {@inheritdoc}
@@ -53,16 +52,6 @@ private static function prepareRequest(?string $method, ?string $url, array $opt
5352
}
5453
}
5554

56-
if (null === self::$emptyDefaults) {
57-
self::$emptyDefaults = [];
58-
59-
foreach ($defaultOptions as $k => $v) {
60-
if (null !== $v) {
61-
self::$emptyDefaults[$k] = $v;
62-
}
63-
}
64-
}
65-
6655
$options = self::mergeDefaultOptions($options, $defaultOptions, $allowExtraOptions);
6756

6857
$buffer = $options['buffer'] ?? true;
@@ -212,11 +201,7 @@ private static function mergeDefaultOptions(array $options, array $defaultOption
212201

213202
$options += $defaultOptions;
214203

215-
if (null === self::$emptyDefaults) {
216-
self::$emptyDefaults = [];
217-
}
218-
219-
foreach (self::$emptyDefaults as $k => $v) {
204+
foreach (self::$emptyDefaults ?? [] as $k => $v) {
220205
if (!isset($options[$k])) {
221206
$options[$k] = $v;
222207
}

NativeHttpClient.php

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

3939
private $defaultOptions = self::OPTIONS_DEFAULTS;
40+
private static $emptyDefaults = self::OPTIONS_DEFAULTS;
4041

4142
/** @var NativeClientState */
4243
private $multi;

Tests/CurlHttpClientTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,6 @@ public function testHandleIsReinitOnReset()
7171
self::assertNotSame($initialShareId, $clientState->share);
7272
}
7373

74-
public function testNullBody()
75-
{
76-
$httpClient = $this->getHttpClient(__FUNCTION__);
77-
78-
$httpClient->request('POST', 'http://localhost:8057/post', [
79-
'body' => null,
80-
]);
81-
82-
$this->expectNotToPerformAssertions();
83-
}
84-
8574
public function testProcessAfterReset()
8675
{
8776
$client = $this->getHttpClient(__FUNCTION__);

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)