Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf190e9e

Browse files
bug#44671 [HttpClient] Fix tracing requests made after calling withOptions() (nicolas-grekas)
This PR was merged into the 5.3 branch.Discussion----------[HttpClient] Fix tracing requests made after calling withOptions()| Q | A| ------------- | ---| Branch? | 5.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#44312| License | MIT| Doc PR | -Commits-------06b25c7 [HttpClient] Fix tracing requests made after calling withOptions()
2 parentsad3010b +06b25c7 commitf190e9e

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

‎src/Symfony/Component/HttpClient/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+
publicfunctiontestWithOptions()
223+
{
224+
$sut =newTraceableHttpClient(newNativeHttpClient());
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
}

‎src/Symfony/Component/HttpClient/TraceableHttpClient.php‎

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

3333
publicfunction__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
publicfunctiongetTracedRequests():array
8687
{
87-
return$this->tracedRequests;
88+
return$this->tracedRequests->getArrayCopy();
8889
}
8990

9091
publicfunctionreset()
@@ -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)

[8]ページ先頭

©2009-2025 Movatter.jp