Skip to content

Commit 983d382

Browse files
[HttpClient] Don't reset timeout counter when initializing requests
1 parent 14d2fd5 commit 983d382

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

Response/CurlResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public function __construct(CurlClientState $multi, $ch, array $options = null,
148148
};
149149

150150
// Schedule the request in a non-blocking way
151+
$multi->lastTimeout = null;
151152
$multi->openHandles[$id] = [$ch, $options];
152153
curl_multi_add_handle($multi->handle, $ch);
153154

Response/NativeResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ private function open(): void
183183
return;
184184
}
185185

186+
$this->multi->lastTimeout = null;
186187
$this->multi->openHandles[$this->id] = [$h, $this->buffer, $this->onProgress, &$this->remaining, &$this->info];
187188
}
188189

Response/ResponseTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,15 +233,15 @@ abstract protected static function perform(ClientState $multi, array &$responses
233233
*/
234234
abstract protected static function select(ClientState $multi, float $timeout): int;
235235

236-
private static function initialize(self $response, float $timeout = null): void
236+
private static function initialize(self $response): void
237237
{
238238
if (null !== $response->info['error']) {
239239
throw new TransportException($response->info['error']);
240240
}
241241

242242
try {
243-
if (($response->initializer)($response, $timeout)) {
244-
foreach (self::stream([$response], $timeout) as $chunk) {
243+
if (($response->initializer)($response, -0.0)) {
244+
foreach (self::stream([$response], -0.0) as $chunk) {
245245
if ($chunk->isFirst()) {
246246
break;
247247
}
@@ -304,7 +304,7 @@ private function doDestruct()
304304
$this->shouldBuffer = true;
305305

306306
if ($this->initializer && null === $this->info['error']) {
307-
self::initialize($this, -0.0);
307+
self::initialize($this);
308308
$this->checkStatusCode();
309309
}
310310
}

Tests/MockHttpClientTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ protected function getHttpClient(string $testCase): HttpClientInterface
157157
$this->markTestSkipped('Real transport required');
158158
break;
159159

160+
case 'testTimeoutOnInitialize':
160161
case 'testTimeoutOnDestruct':
161162
$this->markTestSkipped('Real transport required');
162163
break;

Tests/NativeHttpClientTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public function testInformationalResponseStream()
2626
$this->markTestSkipped('NativeHttpClient doesn\'t support informational status codes.');
2727
}
2828

29+
public function testTimeoutOnInitialize()
30+
{
31+
$this->markTestSkipped('NativeHttpClient doesn\'t support opening concurrent requests.');
32+
}
33+
2934
public function testTimeoutOnDestruct()
3035
{
3136
$this->markTestSkipped('NativeHttpClient doesn\'t support opening concurrent requests.');

0 commit comments

Comments
 (0)