Skip to content

Commit 95c7658

Browse files
[HttpClient] Don't reset timeout counter when initializing requests
1 parent cf2984f commit 95c7658

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

HttpClient/Test/HttpClientTestCase.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,39 @@ public function testTimeoutWithActiveConcurrentStream()
810810
}
811811
}
812812

813+
public function testTimeoutOnInitialize()
814+
{
815+
$p1 = TestHttpServer::start(8067);
816+
$p2 = TestHttpServer::start(8077);
817+
818+
$client = $this->getHttpClient(__FUNCTION__);
819+
$start = microtime(true);
820+
$responses = [];
821+
822+
$responses[] = $client->request('GET', 'http://localhost:8067/timeout-header', ['timeout' => 0.25]);
823+
$responses[] = $client->request('GET', 'http://localhost:8077/timeout-header', ['timeout' => 0.25]);
824+
$responses[] = $client->request('GET', 'http://localhost:8067/timeout-header', ['timeout' => 0.25]);
825+
$responses[] = $client->request('GET', 'http://localhost:8077/timeout-header', ['timeout' => 0.25]);
826+
827+
try {
828+
foreach ($responses as $response) {
829+
try {
830+
$response->getContent();
831+
$this->fail(TransportExceptionInterface::class.' expected');
832+
} catch (TransportExceptionInterface $e) {
833+
}
834+
}
835+
$responses = [];
836+
837+
$duration = microtime(true) - $start;
838+
839+
$this->assertLessThan(1.0, $duration);
840+
} finally {
841+
$p1->stop();
842+
$p2->stop();
843+
}
844+
}
845+
813846
public function testTimeoutOnDestruct()
814847
{
815848
$p1 = TestHttpServer::start(8067);

0 commit comments

Comments
 (0)