-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Bug fix: Replace header when sending first one of each header #2441
Conversation
Hi, just my 2 cents opinion, but i believe this modification could break some applications who use multiple header. I think for example to the header Content-Security-Policy you could use multiple headers with cumulative policies. With this modification only the first header will be sent. But this case is probably rare... Keep up the good work. |
@@ -1742,6 +1763,80 @@ public function testResponseWithStreamReadYieldingLessBytesThanAsked() | |||
$this->expectOutputString(str_repeat('.', Mocks\SmallChunksStream::SIZE)); | |||
} | |||
|
|||
public function testResponseReplacesPreviouslySetHeaders() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about using a dataProvider
and trying to pass the test using "strange" values too?
@ncou That's not what this patch does. It will allow multiple This patch replaces headers set by |
hummm i think i am starting to understand (or perhaps not :)). In fact this patch will replace (one time) the header if it's already present in the header() list. To sumup it will overwrite the possible headers added by the server (like for example the "Cache-Control" header). And for the Set-Cookie it will do an exception and not replace the first occurrence, because it could be added by the server (i suppose it's to handle the case with the session cookies). |
@ncou pretty much, yes. |
thank you it's more clear. 👍 |
When we call
header()
to send the headers in the Response, set thereplace
parameter to true for the first of that header name and thenset it to false.
Don't do this if the header is Set-Cookie so we don't break sessions.
Fixes #2282
Fixes #2246