Skip to content

Commit

Permalink
Merge pull request #151 from adriansuter/patch-response-headers
Browse files Browse the repository at this point in the history
Fix Authorization Headers
  • Loading branch information
l0gicgate committed Feb 9, 2020
2 parents 1f8bb50 + 3ae1689 commit 316ff1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function __construct(
?StreamInterface $body = null
) {
$this->status = $this->filterStatus($status);
$this->headers = $headers ? $headers : new Headers();
$this->headers = $headers ? $headers : new Headers([], []);
$this->body = $body ? $body : (new StreamFactory())->createStream();
}

Expand Down
15 changes: 14 additions & 1 deletion tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use Slim\Psr7\Environment;
use Slim\Psr7\Headers;
use Slim\Psr7\Response;
use Slim\Psr7\Stream;
Expand Down Expand Up @@ -146,7 +147,7 @@ public function testEmptyReasonPhraseForUnrecognisedCode()
{
$response = new Response();
$response = $response->withStatus(199);

$this->assertSame('', $response->getReasonPhrase());
}

Expand All @@ -165,4 +166,16 @@ public function testGetCustomReasonPhrase()

$this->assertEquals('Custom Phrase', $clone->getReasonPhrase());
}

public function testResponseHeadersDoNotContainAuthorizationHeader()
{
$_SERVER = Environment::mock(
[
'PHP_AUTH_USER' => 'foo'
]
);

$response = new Response();
$this->assertEmpty($response->getHeaders());
}
}

0 comments on commit 316ff1c

Please sign in to comment.