Commit 2a70f68
committed
bug #38520 [HttpClient] Fix nesteed stream in AsyncResponse (jderusse)
This PR was merged into the 5.x branch.
Discussion
----------
[HttpClient] Fix nesteed stream in AsyncResponse
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | #38509
| License | MIT
| Doc PR | /
When streaming twice (streaming inside streaming) an AsycResponse the second stream will yield the LastChunk, but the first Stream won't have access to it and ends with an exception `A chunk passthru must yield an "isLast()" chunk`
This PR adds a state in AsyncRsponse to remember if the lastChunk has been yielded.
Reproducer:
```php
// a Simple Client that return an AsyncResponse
$client = new class(HttpClient::create()) implements HttpClientInterface {
use AsyncDecoratorTrait;
private $client;
public function __construct(HttpClientInterface $client)
{
$this->client = $client;
}
public function request(string $method, string $url, array $options = []): ResponseInterface
{
return new AsyncResponse($this->client, $method, $url, $options, null);
}
};
$response = $client->request('GET', 'https://httpbin.org/status/200');
foreach ($client->stream($response) as $chunk) { // will end in a FirstChunk <== bug
foreach ($client->stream($response) as $chunk) { // This will correctly handle the LastChunk
}
}
```
Commits
-------
8ba54c1 Fix nesteed stream in AsyncResponseFile tree
2 files changed
+28
-1
lines changed- src/Symfony/Component/HttpClient
- Response
- Tests
2 files changed
+28
-1
lines changedLines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
255 | 256 | | |
256 | 257 | | |
257 | 258 | | |
258 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
259 | 263 | | |
260 | 264 | | |
261 | 265 | | |
| |||
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
233 | 256 | | |
0 commit comments