8000 Fix content not reported in TracableResponse decorated by AsyncResponse · symfony/symfony@277403e · GitHub
[go: up one dir, main page]

Skip to content

Commit 277403e

Browse files
committed
Fix content not reported in TracableResponse decorated by AsyncResponse
1 parent fdf9a43 commit 277403e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Symfony/Component/HttpClient/Response/TraceableResponse.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ public static function stream(HttpClientInterface $client, iterable $responses,
132132
}
133133

134134
foreach ($client->stream($wrappedResponses, $timeout) as $r => $chunk) {
135+
if (false !== $traceableMap[$r]->content && null === $chunk->getError()) {
136+
$traceableMap[$r]->content .= $chunk->getContent();
137+
}
135138
yield $traceableMap[$r] => $chunk;
136139
}
137140
}

src/Symfony/Component/HttpClient/Tests/TraceableHttpClientTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,17 @@ public function testStream()
115115
$this->assertGreaterThan(1, \count($chunks));
116116
$this->assertSame('Symfony is awesome!', implode('', $chunks));
117117
}
118+
119+
public function testStreamCollectContent()
120+
{
121+
$sut = new TraceableHttpClient(new NativeHttpClient());
122+
$response = $sut->request('GET', 'http://localhost:8057/json/1');
123+
foreach ($sut->stream($response) as $chunk) {
124+
// no-op
125+
}
126+
127+
$this->assertCount(1, $tracedRequests = $sut->getTracedRequests());
128+
$actualTracedRequest = $tracedRequests[0];
129+
$this->assertSame('{"title":"\\/json\\/1"}', $actualTracedRequest['content']);
130+
}
118131
}

0 commit comments

Comments
 (0)
0