fix: prioritize headers set by the Response
class
#9235
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR changes the way headers are set. Now headers set by the
Response
class will be prioritized and will replace those set by calling theheader()
function.Why is this important? Without this change, we cannot override the headers set previously with the
header()
function.This is relevant, especially when we work with a session. By default,
session.cache_limiter
is set tonocache
, which is fine for the default setting and will automatically set headers:But we have no option to change these headers, even when we set different
Cache-Control
etc with theResponse
class. If we do so, we end up with two entries forCache-Control
, which will possibly lead to unexpected behavior. We also cannot remove the default headers set bysession.cache_limiter
, because they are set with theheader()
function directly.Headers set with the
Response
class should be prioritized. This is potentially a BC break, but also a bugfix.Ref: #9234
Checklist: