Skip to content

Commit 62111be

Browse files
Merge branch '5.4' into 6.0
* 5.4: [5.4] cs fixes [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 Revert "feature #41989 [Cache] make `LockRegistry` use semaphores when possible (nicolas-grekas)" [HttpKernel] fix how configuring log-level and status-code by exception works [VarDumper] add more "transient-on-macos" groups
2 parents a93a77c + d6c0e0e commit 62111be

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
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/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 array $tracedRequests = [];
3130
private $stopwatch;
31+
private \ArrayObject $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
/**
@@ -82,7 +83,7 @@ public function stream(ResponseInterface|iterable $responses, float $timeout = n
8283

8384
public function getTracedRequests(): array
8485
{
85-
return $this->tracedRequests;
86+
return $this->tracedRequests->getArrayCopy();
8687
}
8788

8889
public function reset()
@@ -91,7 +92,7 @@ public function reset()
9192
$this->client->reset();
9293
}
9394

94-
$this->tracedRequests = [];
95+
$this->tracedRequests->exchangeArray([]);
9596
}
9697

9798
/**

0 commit comments

Comments
 (0)