Merge pull request #7763 from creative-commoners/pulls/4.0/fix-remove-header

FIX HTTPResponse::removeHeader incorrectly converts header name to lowercase
This commit is contained in:
Loz Calver 2018-01-16 11:04:03 +00:00 committed by GitHub
commit daac577e62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -245,7 +245,7 @@ class HTTPResponse
*/ */
public function removeHeader($header) public function removeHeader($header)
{ {
strtolower($header); $header = strtolower($header);
unset($this->headers[$header]); unset($this->headers[$header]);
return $this; return $this;
} }

View File

@ -47,4 +47,15 @@ class HTTPResponseTest extends SapphireTest
// Fail if we get to here // Fail if we get to here
$this->assertFalse(true, 'Something went wrong with our test exception'); $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'));
}
} }