From 9e4176a8478224c4455549ad46bcefbd6f20dac8 Mon Sep 17 00:00:00 2001 From: james Date: Mon, 31 Dec 2018 00:23:56 -0500 Subject: [PATCH] Added test that improperly prefixed headers are not returned by marshalHeadersFromSapi --- test/ServerRequestFactoryTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/ServerRequestFactoryTest.php b/test/ServerRequestFactoryTest.php index 16f57726..2e922a08 100644 --- a/test/ServerRequestFactoryTest.php +++ b/test/ServerRequestFactoryTest.php @@ -60,6 +60,23 @@ public function testMarshalsExpectedHeadersFromServerArray() $this->assertSame($expected, marshalHeadersFromSapi($server)); } + public function testMarshalInvalidHeadersStrippedFromServerArray() + { + $server = [ + 'COOKIE' => 'COOKIE', + 'HTTP_AUTHORIZATION' => 'token', + 'MD5' => 'CONTENT-MD5', + 'CONTENT_LENGTH' => 'UNSPECIFIED', + ]; + + //Headers that don't begin with HTTP_ or CONTENT_ will not be returned + $expected = [ + 'authorization' => 'token', + 'content-length' => 'UNSPECIFIED', + ]; + $this->assertSame($expected, marshalHeadersFromSapi($server)); + } + public function testMarshalsVariablesPrefixedByApacheFromServerArray() { // Non-prefixed versions will be preferred