From cc90cb012583abd675b8c5e41044603f0b9e39cb Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Tue, 16 Jan 2018 23:20:52 +1300 Subject: [PATCH] FIX HTTPResponse::removeHeader incorrectly converts header name to lowercase --- src/Control/HTTPResponse.php | 2 +- tests/php/Control/HTTPResponseTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Control/HTTPResponse.php b/src/Control/HTTPResponse.php index 67c378fba..f26a5f50a 100644 --- a/src/Control/HTTPResponse.php +++ b/src/Control/HTTPResponse.php @@ -245,7 +245,7 @@ class HTTPResponse */ public function removeHeader($header) { - strtolower($header); + $header = strtolower($header); unset($this->headers[$header]); return $this; } diff --git a/tests/php/Control/HTTPResponseTest.php b/tests/php/Control/HTTPResponseTest.php index d527e2ee9..3457b6985 100644 --- a/tests/php/Control/HTTPResponseTest.php +++ b/tests/php/Control/HTTPResponseTest.php @@ -47,4 +47,15 @@ class HTTPResponseTest extends SapphireTest // Fail if we get to here $this->assertFalse(true, 'Something went wrong with our test exception'); } + + public function testRemoveHeader() + { + $response = new HTTPResponse(); + + $response->addHeader('X-Animal', 'Monkey'); + $this->assertSame('Monkey', $response->getHeader('X-Animal')); + + $response->removeHeader('X-Animal'); + $this->assertEmpty($response->getHeader('X-Animal')); + } }