bug #22285 [HttpKernel] Fix forward compat with Request::setTrustedProxies() (nicolas-grekas)
This PR was merged into the 3.2 branch.
Discussion
----------
[HttpKernel] Fix forward compat with Request::setTrustedProxies()
| Q | A
| ------------- | ---
| Branch? | 3.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Should make travis green again.
Commits
-------
6ecec35
[HttpKernel] Fix forward compat with Request::setTrustedProxies()
This commit is contained in:
commit
db8231e6d0
@ -36,7 +36,7 @@ class WebProcessorTest extends TestCase
|
||||
|
||||
public function testUseRequestClientIp()
|
||||
{
|
||||
Request::setTrustedProxies(array('192.168.0.1'));
|
||||
Request::setTrustedProxies(array('192.168.0.1'), -1);
|
||||
list($event, $server) = $this->createRequestEvent(array('X_FORWARDED_FOR' => '192.168.0.2'));
|
||||
|
||||
$processor = new WebProcessor();
|
||||
|
@ -464,7 +464,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
// make sure HttpCache is a trusted proxy
|
||||
if (!in_array('127.0.0.1', $trustedProxies = Request::getTrustedProxies())) {
|
||||
$trustedProxies[] = '127.0.0.1';
|
||||
Request::setTrustedProxies($trustedProxies);
|
||||
Request::setTrustedProxies($trustedProxies, method_exists('Request', 'getTrustedHeaderSet') ? Request::getTrustedHeaderSet() : -1);
|
||||
}
|
||||
|
||||
// always a "master" request (as the real master request can be in cache)
|
||||
|
@ -30,7 +30,7 @@ class ValidateRequestListenerTest extends TestCase
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
|
||||
|
||||
$request = new Request();
|
||||
$request->setTrustedProxies(array('1.1.1.1'));
|
||||
$request->setTrustedProxies(array('1.1.1.1'), -1);
|
||||
$request->server->set('REMOTE_ADDR', '1.1.1.1');
|
||||
$request->headers->set('FORWARDED', 'for=2.2.2.2');
|
||||
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
|
||||
|
@ -1218,7 +1218,7 @@ class HttpCacheTest extends HttpCacheTestCase
|
||||
*/
|
||||
public function testHttpCacheIsSetAsATrustedProxy(array $existing, array $expected)
|
||||
{
|
||||
Request::setTrustedProxies($existing);
|
||||
Request::setTrustedProxies($existing, -1);
|
||||
|
||||
$this->setNextResponse();
|
||||
$this->request('GET', '/', array('REMOTE_ADDR' => '10.0.0.1'));
|
||||
|
@ -309,7 +309,7 @@ class HttpKernelTest extends TestCase
|
||||
public function testInconsistentClientIpsOnMasterRequests()
|
||||
{
|
||||
$request = new Request();
|
||||
$request->setTrustedProxies(array('1.1.1.1'));
|
||||
$request->setTrustedProxies(array('1.1.1.1'), -1);
|
||||
$request->server->set('REMOTE_ADDR', '1.1.1.1');
|
||||
$request->headers->set('FORWARDED', 'for=2.2.2.2');
|
||||
$request->headers->set('X_FORWARDED_FOR', '3.3.3.3');
|
||||
|
Reference in New Issue
Block a user