summaryrefslogtreecommitdiff
path: root/vendor/symfony/http-foundation/Tests/RequestTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/http-foundation/Tests/RequestTest.php')
-rw-r--r--vendor/symfony/http-foundation/Tests/RequestTest.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/symfony/http-foundation/Tests/RequestTest.php b/vendor/symfony/http-foundation/Tests/RequestTest.php
index 3c123656cc..3c4a13acf4 100644
--- a/vendor/symfony/http-foundation/Tests/RequestTest.php
+++ b/vendor/symfony/http-foundation/Tests/RequestTest.php
@@ -2195,6 +2195,36 @@ class RequestTest extends TestCase
Request::setTrustedHeaderName(Request::HEADER_CLIENT_PROTO, 'X_FORWARDED_PROTO');
}
+ /**
+ * @dataProvider protocolVersionProvider
+ */
+ public function testProtocolVersion($serverProtocol, $trustedProxy, $via, $expected)
+ {
+ if ($trustedProxy) {
+ Request::setTrustedProxies(array('1.1.1.1'), -1);
+ }
+
+ $request = new Request();
+ $request->server->set('SERVER_PROTOCOL', $serverProtocol);
+ $request->server->set('REMOTE_ADDR', '1.1.1.1');
+ $request->headers->set('Via', $via);
+
+ $this->assertSame($expected, $request->getProtocolVersion());
+ }
+
+ public function protocolVersionProvider()
+ {
+ return array(
+ 'untrusted without via' => array('HTTP/2.0', false, '', 'HTTP/2.0'),
+ 'untrusted with via' => array('HTTP/2.0', false, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/2.0'),
+ 'trusted without via' => array('HTTP/2.0', true, '', 'HTTP/2.0'),
+ 'trusted with via' => array('HTTP/2.0', true, '1.0 fred, 1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'),
+ 'trusted with via and protocol name' => array('HTTP/2.0', true, 'HTTP/1.0 fred, HTTP/1.1 nowhere.com (Apache/1.1)', 'HTTP/1.0'),
+ 'trusted with broken via' => array('HTTP/2.0', true, 'HTTP/1^0 foo', 'HTTP/2.0'),
+ 'trusted with partially-broken via' => array('HTTP/2.0', true, '1.0 fred, foo', 'HTTP/1.0'),
+ );
+ }
+
public function nonstandardRequestsData()
{
return array(