Skip to content
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

Document how resp is affected by raising HTTPError/HTTPStatus #2221

Open
vytas7 opened this issue Apr 2, 2024 · 3 comments
Open

Document how resp is affected by raising HTTPError/HTTPStatus #2221

vytas7 opened this issue Apr 2, 2024 · 3 comments
Labels
documentation good first issue needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks!
Milestone

Comments

@vytas7
Copy link
Member

vytas7 commented Apr 2, 2024

As pointed out by @onecrayon on Gitter, at the time of writing, it is not very clear what happens with data attributes/headers/cookies already set on resp in the case an instance of HTTPError or HTTPStatus is raised.

The correct answer for the 3.x series is that resp.data, .text, .media, etc are reset, but headers and cookies persist unless they are overwritten by headers passed into HTTPError.

Another undocumented surprise is that passing Set-Cookie in headers will bubble up an unhandled falcon.errors.HeaderNotSupported to the app server.

See also: #1752.

@vytas7 vytas7 added this to the Version 4.x milestone Apr 2, 2024
@vytas7 vytas7 added documentation good first issue needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks! labels Apr 2, 2024
@vytas7
Copy link
Member Author

vytas7 commented Apr 2, 2024

TBD: do we need any code changes here, or is clearly documenting the current behaviour good enough?

@onecrayon
Copy link

Clear documentation would be sufficient for my needs, personally, but mainly because I still want to send cookies along with redirects. I could also see an argument for the redirects using a completely new response, though, because it’s two lines to explicitly send a redirect while maintaining the response otherwise (set the status, set the header).

@CaselIT
Copy link
Member

CaselIT commented Apr 2, 2024

If we were to implement #1752 also for http status/error it would be feasible to add an attribute to them called override_request that means "discard everything in request and use things only from this object".

The default would be False to keep the current behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation good first issue needs contributor Comment on this issue if you'd like to volunteer to work on this. Thanks!
Projects
None yet
Development

No branches or pull requests

3 participants