-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix HEAD requests for static content #4813
Conversation
FileResponse directly injects the response into the socket with sendfile() (if it can), which bypasses the checks in Response that prevent any content being sent for HEAD requests and for 204 (No Content) and 304 (Not Modified) responses. I've duplicated that logic into FileResponse. I'm not sure if the status checks are actually applicable (since StaticResource already has its own handling for Not Modified) and I don't currently have any tests for them. Closes aio-libs#4809.
Codecov Report
@@ Coverage Diff @@
## master #4813 +/- ##
=======================================
Coverage 97.60% 97.60%
=======================================
Files 43 43
Lines 8932 8934 +2
Branches 1406 1407 +1
=======================================
+ Hits 8718 8720 +2
Misses 95 95
Partials 119 119
Continue to review full report at Codecov.
|
StreamWriter.wait_closed doesn't exist on 3.6.
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, makes sense.
Thanks for the fix!
💔 Backport was not successfulThe PR was attempted backported to the following branches:
|
* Fix HEAD requests for static content FileResponse directly injects the response into the socket with sendfile() (if it can), which bypasses the checks in Response that prevent any content being sent for HEAD requests and for 204 (No Content) and 304 (Not Modified) responses. I've duplicated that logic into FileResponse. I'm not sure if the status checks are actually applicable (since StaticResource already has its own handling for Not Modified) and I don't currently have any tests for them. Closes #4809.
* Fix HEAD requests for static content FileResponse directly injects the response into the socket with sendfile() (if it can), which bypasses the checks in Response that prevent any content being sent for HEAD requests and for 204 (No Content) and 304 (Not Modified) responses. I've duplicated that logic into FileResponse. I'm not sure if the status checks are actually applicable (since StaticResource already has its own handling for Not Modified) and I don't currently have any tests for them. Closes #4809.
What do these changes do?
It makes HEAD requests work correctly for static resources.
FileResponse directly injects the response into the socket with
sendfile() (if it can), which bypasses the checks in Response that
prevent any content being sent for HEAD requests and for 204 (No
Content) and 304 (Not Modified) responses. I've duplicated that logic
into FileResponse. I'm not sure if the status checks are actually
applicable (since StaticResource already has its own handling for Not
Modified) and I don't currently have any tests for them.
Are there changes in behavior for the user?
Bugfix only.
Related issue number
#4809
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.