Skip to content

Commit 8e02469

Browse files
[HttpClient] fix canceling responses in a streaming loop
1 parent 6db12f0 commit 8e02469

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Test/HttpClientTestCase.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,21 @@ public function testCancel()
505505
$response->getHeaders();
506506
}
507507

508+
public function testCancelInStream()
509+
{
510+
$client = $this->getHttpClient(__FUNCTION__);
511+
$response = $client->request('GET', 'http://localhost:8057/404');
512+
513+
foreach ($client->stream($response) as $chunk) {
514+
$response->cancel();
515+
}
516+
517+
$this->expectException(TransportExceptionInterface::class);
518+
519+
foreach ($client->stream($response) as $chunk) {
520+
}
521+
}
522+
508523
public function testOnProgressCancel()
509524
{
510525
$client = $this->getHttpClient(__FUNCTION__);

0 commit comments

Comments
 (0)