8000 Do not override max_redirects · symfony/symfony@d11ed98 · GitHub
[go: up one dir, main page]

Skip to content

Commit d11ed98

Browse files
committed
Do not override max_redirects
#38207
1 parent cae08a0 commit d11ed98

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/Symfony/Component/HttpKernel/HttpClientKernel.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQ
5353
$response = $this->client->request($request->getMethod(), $request->getUri(), [
5454
'headers' => $headers,
5555
'body' => $body,
56-
'max_redirects' => 0,
5756
] + $request->attributes->get('http_client_options', []));
5857

5958
$response = new Response($response->getContent(!$catch), $response->getStatusCode(), $response->getHeaders(!$catch));
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpKernel\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\Request;
16+
use Symfony\Component\HttpKernel\HttpClientKernel;
17+
use Symfony\Contracts\HttpClient\HttpClientInterface;
18+
use Symfony\Contracts\HttpClient\ResponseInterface;
19+
20+
class HttpClientKernelTest extends TestCase
21+
{
22+
public function testHandlePassesMaxRedirectsHttpClientOption()
23+
{
24+
$request = new Request();
25+
$request->attributes->set('http_client_options', ['max_redirects' => 50]);
26+
27+
$response = $this->getMockBuilder(ResponseInterface::class)->getMock();
28+
$response->expects($this->once())->method('getStatusCode')->willReturn(200);
29+
30+
$client = $this->getMockBuilder(HttpClientInterface::class)->getMock();
31+
$client
32+
->expects($this->once())
33+
->method('request')
34+
->willReturnCallback(function (string $method, string $uri, array $options) use ($request, $response) {
35+
$this->assertSame($request->getMethod(), $method);
36+
$this->assertSame($request->getUri(), $uri);
37+
$this->assertArrayHasKey('max_redirects', $options);
38+
$this->assertSame(50, $options['max_redirects']);
39+
40+
return $response;
41+
});
42+
43+
$kernel = new HttpClientKernel($client);
44+
$kernel->handle($request);
45+
}
46+
}

0 commit comments

Comments
 (0)
0