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

fixed 204/304 HTTPException handling #4952

Closed
wants to merge 3 commits into from

Conversation

bentheiii
Copy link

  1. responses with 204/304 status codes shouldn't ever have content
  2. If headers are provided as part of the HTTPException, their "content-length" and "content-type" should be removed, since they'll need to be overridden for the new response.

closes #4949

@codecov
Copy link

codecov bot commented May 25, 2022

Codecov Report

Merging #4952 (5280307) into master (ab8988f) will decrease coverage by 0.01%.
The diff coverage is 85.71%.

@@             Coverage Diff             @@
##            master    #4952      +/-   ##
===========================================
- Coverage   100.00%   99.98%   -0.02%     
===========================================
  Files          533      533              
  Lines        13725    13734       +9     
===========================================
+ Hits         13725    13732       +7     
- Misses           0        2       +2     
Impacted Files Coverage Δ
fastapi/exception_handlers.py 90.90% <85.71%> (-9.10%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@github-actions
Copy link
Contributor

📝 Docs preview for commit b2d5b28 at: https://628e3e766bc9ba22f5eba971--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 78a589a at: https://628e3f8fe8c1f9239209a94e--fastapi.netlify.app

@fboerman
Copy link

this seems to be a fix for #4939

@fboerman
Copy link

I can confirm this fixes my problem when using:

raise HTTPException(status_code=HTTP_304_NOT_MODIFIED)

@tiangolo
Copy link
Owner

tiangolo commented Sep 3, 2022

Thanks for the contribution! It seems this was handled in #5145, available since FastAPI 0.79.0. So I'll close this one. But if you feel there's anything else to be done, feel free to add a new PR. Thanks! ☕

@tiangolo tiangolo closed this Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FastApi Error : "RuntimeError: Response content longer than Content-Length"
3 participants