-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] minor: add ability to construct with headers on http exceptions #22228
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
[HttpKernel] minor: add ability to construct with headers on http exceptions #22228
Conversation
f4a21dd
to
c9fd589
Compare
All the array_merge could be replaced by a simple affectation: |
@nicolas-grekas Thanks! Good spot, will update. |
c9fd589
to
098006f
Compare
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.
LGTM
src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php
Outdated
Show resolved
Hide resolved
An oversight, will fix the others up also. |
Status: needs work |
098006f
to
612fb59
Compare
Updated. |
Thank you @gsdevme. |
…ers on http exceptions (gsdevme) This PR was merged into the 4.0-dev branch. Discussion ---------- [HttpKernel] minor: add ability to construct with headers on http exceptions | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This adds the ability to set the headers for the exception within the constructor. With alot of the following exceptions its sometimes very useful to be able to set the headers. For example with a reverse proxy cache (Varnish) if you want to match the `Retry-After` with a Varnish cache header to protect the backend. I see that `setHeaders()` did get added 6a1080f but that means the exception needs to be assigned to a variable and set and then thrown, it also doesn't merge with the existing header set in some of the constructors. ~~I've chosen to `array_merge()` where key/values~~ were being set within the constructor as I think this is the most useful and 'correct' whereas `setHeaders` is explicit that its setting not amending or adding to. Commits ------- 612fb59 [HttpKernel] minor: add ability to construct with headers on http exceptions
For future reference although this has a milestone of 3.4, its only in 4.0+ |
This adds the ability to set the headers for the exception within the constructor.
With alot of the following exceptions its sometimes very useful to be able to set the headers. For example with a reverse proxy cache (Varnish) if you want to match the
Retry-After
with a Varnish cache header to protect the backend.I see that
setHeaders()
did get added 6a1080f but that means the exception needs to be assigned to a variable and set and then thrown, it also doesn't merge with the existing header set in some of the constructors.I've chosen towere being set within the constructor as I think this is the most useful and 'correct' whereasarray_merge()
where key/valuessetHeaders
is explicit that its setting not amending or adding to.