Closed
Description
Symfony version(s) affected: ^4.3.0
Description
I use the http client for a GET
request. By default an instance of Symfony\Component\HttpClient\HttpClient
follows redirects (by default up to 20). When using the Symfony\Component\HttpClient\CachingHttpClient
every redirect leads to an exception.
The issue is caused by the Symfony\Component\HttpKernel\HttpClientKernel
which overrides the max_redirects
option:
symfony/src/Symfony/Component/HttpKernel/HttpClientKernel.php
Lines 53 to 57 in 9c8cd08
How to reproduce
<?php
$client = Symfony\Component\HttpClient\HttpClient::create();
$cachingClient = new Symfony\Component\HttpClient\CachingHttpClient(
$client,
new Symfony\Component\HttpKernel\HttpCache\Store('/path/to/the/cache')
);
// Work as expectede
$client->request(
'GET',
// Redirect to https://api.github.com/repositories/109533757/git/matching-refs/tags/ happens here
'https://api.github.com/repos/humbug/box/git/matching-refs/tags/',
['headers' => ['Authorization' => 'token XXX']
);
// Throws Symfony\Component\HttpClient\Exception\RedirectionException
$cachingClient->request(
'GET',
// Redirect to https://api.github.com/repositories/109533757/git/matching-refs/tags/ happens here
'https://api.github.com/repos/humbug/box/git/matching-refs/tags/',
['headers' => ['Authorization' => 'token XXX']
);
Additional context