-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response headers include received Authorization header #130
Comments
We need to fix this @adriansuter . This is definitely a bug. We may have to create |
Isn't it possible to simply provide the globals here, or do we need them elsewhere? Line 127 in 1f8bb50
That is $this->headers = $headers ? $headers : new Headers([], []); I quickly made a test and run phpunit. // \Slim\Tests\Psr7\ResponseTest
public function testResponseHeadersDoNotContainAuthorizationHeader()
{
$_SERVER = Environment::mock(
[
'PHP_AUTH_USER' => 'foo'
]
);
$response = new Response();
$this->assertEmpty($response->getHeaders());
} The test fails without the modification mentioned above. But with the change, all tests succeed. Could that be a BC? Is it too hackish? |
@l0gicgate what do you think? |
@adriansuter that would also work yes. Probably the simplest fix. |
The Response constructor will by default create a Headers object to collect headers to be sent. The Headers constructor will call setHeaders() which will call parseAuthorizationHeader(). parseAuthorizationHeader() will try to create an Authorization header from data found in $_SERVER.
The result of this is that the Response headers include a copy of the Authorization header received in the request being processed.
The code comment for parseAuthorizationHeader() reads: "Parse incoming headers and determine Authorization header from original headers". My interpretation is that this code was never intended to be used for a Response.
The text was updated successfully, but these errors were encountered: