Skip to content

Commit 4886bd2

Browse files
Merge branch '4.3' into 4.4
* 4.3: [HttpClient] Fix a bug preventing Server Pushes to be handled properly [HttpClient] fix support for 103 Early Hints and other informational status codes [DI] fix failure [Validator] Add ConstraintValidator::formatValue() tests [HttpClient] improve handling of HTTP/2 PUSH Fix #33427 [Validator] Only handle numeric values in DivisibleBy [Validator] Sync string to date behavior and throw a better exception Check phpunit configuration for listeners [DI] fix support for "!tagged_locator foo"
2 parents 6005fe6 + 8e9d536 commit 4886bd2

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

ChunkInterface.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ public function isFirst(): bool;
4747
*/
4848
public function isLast(): bool;
4949

50+
/**
51+
* Returns a [status code, headers] tuple when a 1xx status code was just received.
52+
*
53+
* @throws TransportExceptionInterface on a network error or when the idle timeout is reached
54+
*/
55+
public function getInformationalStatus(): ?array;
56+
5057
/**
5158
* Returns the content of the response chunk.
5259
*

Test/HttpClientTestCase.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,27 @@ public function testInformationalResponse()
754754
$this->assertSame(200, $response->getStatusCode());
755755
}
756756

757+
public function testInformationalResponseStream()
758+
{
759+
$client = $this->getHttpClient(__FUNCTION__);
760+
$response = $client->request('GET', 'http://localhost:8057/103');
761+
762+
$chunks = [];
763+
foreach ($client->stream($response) as $chunk) {
764+
$chunks[] = $chunk;
765+
}
766+
767+
$this->assertSame(103, $chunks[0]->getInformationalStatus()[0]);
768+
$this->assertSame(['</style.css>; rel=preload; as=style', '</script.js>; rel=preload; as=script'], $chunks[0]->getInformationalStatus()[1]['link']);
769+
$this->assertTrue($chunks[1]->isFirst());
770+
$this->assertSame('Here the body', $chunks[2]->getContent());
771+
$this->assertTrue($chunks[3]->isLast());
772+
$this->assertNull($chunks[3]->getInformationalStatus());
773+
774+
$this->assertSame(['date', 'content-length'], array_keys($response->getHeaders()));
775+
$this->assertContains('Link: </style.css>; rel=preload; as=style', $response->getInfo('response_headers'));
776+
}
777+
757778
/**
758779
* @requires extension zlib
759780
*/

0 commit comments

Comments
 (0)