Skip to content

Commit d6c0e0e

Browse files
Merge branch '5.3' into 5.4
* 5.3: [5.3] cs fixes [Cache] Fix saving items with no expiration through ProxyAdapter CS fixes [HttpClient] Fix tracing requests made after calling withOptions() [Cache] disable lock on CLI [VarDumper] add more "transient-on-macos" groups
2 parents c1fcbee + 5c141de commit d6c0e0e

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

HttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static function create(array $defaultOptions = [], int $maxHostConnection
4444
$curlVersion = $curlVersion ?? curl_version();
4545

4646
// HTTP/2 push crashes before curl 7.61
47-
if (0x073d00 > $curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & $curlVersion['features'])) {
47+
if (0x073D00 > $curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & $curlVersion['features'])) {
4848
return new AmpHttpClient($defaultOptions, null, $maxHostConnections, $maxPendingPushes);
4949
}
5050
}

Response/AmpResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private static function followRedirects(Request $originRequest, AmpClientState $
327327
// Discard body of redirects
328328
while (null !== yield $response->getBody()->read()) {
329329
}
330-
} catch (HttpException | StreamException $e) {
330+
} catch (HttpException|StreamException $e) {
331331
// Ignore streaming errors on previous responses
332332
}
333333

Tests/CurlHttpClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
2727
$this->markTestSkipped('PHP 7.3.0 to 7.3.3 don\'t support HTTP/2 PUSH');
2828
}
2929

30-
if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) {
30+
if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073D00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) {
3131
$this->markTestSkipped('curl <7.61 is used or it is not compiled with support for HTTP/2 PUSH');
3232
}
3333
}

Tests/TraceableHttpClientTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,18 @@ public function testStopwatchDestruct()
218218
$this->assertCount(1, $events['GET http://localhost:8057']->getPeriods());
219219
$this->assertGreaterThan(0.0, $events['GET http://localhost:8057']->getDuration());
220220
}
221+
222+
public function testWithOptions()
223+
{
224+
$sut = new TraceableHttpClient(new NativeHttpClient());
225+
226+
$sut2 = $sut->withOptions(['base_uri' => 'http://localhost:8057']);
227+
228+
$response = $sut2->request('GET', '/');
229+
230+
$this->assertSame(200, $response->getStatusCode());
231+
$this->assertSame('http://localhost:8057/', $response->getInfo('url'));
232+
233+
$this->assertCount(1, $sut->getTracedRequests());
234+
}
221235
}

TraceableHttpClient.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
final class TraceableHttpClient implements HttpClientInterface, ResetInterface, LoggerAwareInterface
2828
{
2929
private $client;
30-
private $tracedRequests = [];
3130
private $stopwatch;
31+
private $tracedRequests;
3232

3333
public function __construct(HttpClientInterface $client, Stopwatch $stopwatch = null)
3434
{
3535
$this->client = $client;
3636
$this->stopwatch = $stopwatch;
37+
$this->tracedRequests = new \ArrayObject();
3738
}
3839

3940
/**
@@ -84,7 +85,7 @@ public function stream($responses, float $timeout = null): ResponseStreamInterfa
8485

8586
public function getTracedRequests(): array
8687
{
87-
return $this->tracedRequests;
88+
return $this->tracedRequests->getArrayCopy();
8889
}
8990

9091
public function reset()
@@ -93,7 +94,7 @@ public function reset()
9394
$this->client->reset();
9495
}
9596

96-
$this->tracedRequests = [];
97+
$this->tracedRequests->exchangeArray([]);
9798
}
9899

99100
/**

0 commit comments

Comments
 (0)