Skip to content

Commit 3d2605c

Browse files
Merge branch '6.4' into 7.0
* 6.4: (21 commits) [ErrorHandler] Add missing self-closing tags on link elements Fix merge (bis) Fix merge Add missing return type [FrameworkBundle] ConfigBuilderCacheWarmer should be non-optional [HttpClient] Fix pausing responses before they start when using curl [Notifier] Updated the NTFY notifier to run without a user parameter [Translation] Fix constant domain resolution in PhpAstExtractor separate child and parent context in NotificationEmail on writes [Mailer] [Mailgun] Fix sender header encoding do not overwrite the cache key when it is false [Mailer] [Scaleway] Fix attachment handling [Mailer] Throw TransportException when unable to read from socket [Serializer] Rewrite `AbstractObjectNormalizer::createChildContext()` to use the provided `cache_key` from original context when creating child contexts Revert #47715 [HttpClient] Fix error chunk creation in passthru Adjusting and removing the 'review' attribute from the pt_br translation XML. [DependencyInjection] Fix loading all env vars from secrets when only a subset is needed Fix option filenameMaxLength to the File constraint (Image) [Serializer] Take unnamed variadic parameters into account when denormalizing ...
2 parents dc4ee0b + a9034bc commit 3d2605c

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

Response/AsyncResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(HttpClientInterface $client, string $method, string
6666
while (true) {
6767
foreach (self::stream([$response], $timeout) as $chunk) {
6868
if ($chunk->isTimeout() && $response->passthru) {
69-
foreach (self::passthru($response->client, $response, new ErrorChunk($response->offset, new TransportException($chunk->getError()))) as $chunk) {
69+
foreach (self::passthru($response->client, $response, new ErrorChunk($response->offset, $chunk->getError())) as $chunk) {
7070
if ($chunk->isFirst()) {
7171
return false;
7272
}

Response/CurlResponse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public function __construct(CurlClientState $multi, \CurlHandle|string $ch, ?arr
9898
$this->info['pause_handler'] = static function (float $duration) use ($ch, $multi, $execCounter) {
9999
if (0 < $duration) {
100100
if ($execCounter === $multi->execCounter) {
101-
$multi->execCounter = !\is_float($execCounter) ? 1 + $execCounter : \PHP_INT_MIN;
102101
curl_multi_remove_handle($multi->handle, $ch);
103102
}
104103

Tests/RetryableHttpClientTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\HttpClient\Exception\ServerException;
16+
use Symfony\Component\HttpClient\Exception\TimeoutException;
1617
use Symfony\Component\HttpClient\HttpClient;
1718
use Symfony\Component\HttpClient\MockHttpClient;
1819
use Symfony\Component\HttpClient\NativeHttpClient;
@@ -21,6 +22,7 @@
2122
use Symfony\Component\HttpClient\Retry\GenericRetryStrategy;
2223
use Symfony\Component\HttpClient\RetryableHttpClient;
2324
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
25+
use Symfony\Contracts\HttpClient\Test\TestHttpServer;
2426

2527
class RetryableHttpClientTest extends TestCase
2628
{
@@ -245,6 +247,35 @@ public function testRetryOnErrorAssertContent()
245247
self::assertSame('Test out content', $response->getContent(), 'Content should be buffered');
246248
}
247249

250+
/**
251+
* @testWith ["GET"]
252+
* ["POST"]
253+
* ["PUT"]
254+
* ["PATCH"]
255+
* ["DELETE"]
256+
*/
257+
public function testRetryOnHeaderTimeout(string $method)
258+
{
259+
$client = HttpClient::create();
260+
261+
if ($client instanceof NativeHttpClient) {
262+
$this->markTestSkipped('NativeHttpClient cannot timeout before receiving headers');
263+
}
264+
265+
TestHttpServer::start();
266+
267+
$client = new RetryableHttpClient($client);
268+
$response = $client->request($method, 'http://localhost:8057/timeout-header', ['timeout' => 0.1]);
269+
270+
try {
271+
$response->getStatusCode();
272+
$this->fail(TimeoutException::class.' expected');
273+
} catch (TimeoutException $e) {
274+
}
275+
276+
$this->assertSame('Idle timeout reached for "http://localhost:8057/timeout-header".', $response->getInfo('error'));
277+
}
278+
248279
public function testRetryWithMultipleBaseUris()
249280
{
250281
$client = new RetryableHttpClient(

0 commit comments

Comments
 (0)