[HttpFoundation] removed obsolete request property
This commit is contained in:
parent
51a3561ed4
commit
168b8cb23e
@ -35,8 +35,6 @@ class Request
|
||||
const HEADER_CLIENT_PROTO = 'client_proto';
|
||||
const HEADER_CLIENT_PORT = 'client_port';
|
||||
|
||||
protected static $trustProxy = false;
|
||||
|
||||
protected static $trustedProxies = array();
|
||||
|
||||
/**
|
||||
@ -476,7 +474,6 @@ class Request
|
||||
public static function setTrustedProxies(array $proxies)
|
||||
{
|
||||
self::$trustedProxies = $proxies;
|
||||
self::$trustProxy = $proxies ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -672,7 +669,7 @@ class Request
|
||||
{
|
||||
$ip = $this->server->get('REMOTE_ADDR');
|
||||
|
||||
if (!self::$trustProxy) {
|
||||
if (!self::$trustedProxies) {
|
||||
return array($ip);
|
||||
}
|
||||
|
||||
@ -683,7 +680,7 @@ class Request
|
||||
$clientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP])));
|
||||
$clientIps[] = $ip;
|
||||
|
||||
$trustedProxies = self::$trustProxy && !self::$trustedProxies ? array($ip) : self::$trustedProxies;
|
||||
$trustedProxies = !self::$trustedProxies ? array($ip) : self::$trustedProxies;
|
||||
$ip = $clientIps[0];
|
||||
$clientIps = array_diff($clientIps, $trustedProxies);
|
||||
|
||||
@ -827,7 +824,7 @@ class Request
|
||||
*/
|
||||
public function getPort()
|
||||
{
|
||||
if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) {
|
||||
if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) {
|
||||
return $port;
|
||||
}
|
||||
|
||||
@ -988,7 +985,7 @@ class Request
|
||||
*/
|
||||
public function isSecure()
|
||||
{
|
||||
if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) {
|
||||
if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) {
|
||||
return in_array(strtolower($proto), array('https', 'on', '1'));
|
||||
}
|
||||
|
||||
@ -1014,7 +1011,7 @@ class Request
|
||||
*/
|
||||
public function getHost()
|
||||
{
|
||||
if (self::$trustProxy && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) {
|
||||
if (self::$trustedProxies && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) {
|
||||
$elements = explode(',', $host);
|
||||
|
||||
$host = $elements[count($elements) - 1];
|
||||
|
@ -666,7 +666,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$request->initialize(array(), array(), array(), array(), array(), array('SERVER_NAME' => 'www.exemple.com', 'HTTP_HOST' => 'www.host.com'));
|
||||
$this->assertEquals('www.host.com', $request->getHost(), '->getHost() value from Host header has priority over SERVER_NAME ');
|
||||
$this->stopTrustingProxyData();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1277,14 +1276,6 @@ class RequestTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
private function stopTrustingProxyData()
|
||||
{
|
||||
$class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request');
|
||||
$property = $class->getProperty('trustProxy');
|
||||
$property->setAccessible(true);
|
||||
$property->setValue(false);
|
||||
}
|
||||
|
||||
private function disableHttpMethodParameterOverride()
|
||||
{
|
||||
$class = new \ReflectionClass('Symfony\\Component\\HttpFoundation\\Request');
|
||||
|
Reference in New Issue
Block a user