Deprecate FileResponse(method=...) parameter#2366
Merged
Conversation
Kludex
commented
Dec 10, 2023
| self.send_header_only = method is not None and method.upper() == "HEAD" | ||
| if method is not None: | ||
| warnings.warn( | ||
| "The 'method' parameter is not used, and it will be removed.", |
Owner
Author
There was a problem hiding this comment.
The method parameter becomes a no-op with this PR, and it's "scheduled" to be removed in 1.0.
Kludex
commented
Dec 10, 2023
tests/test_responses.py
Outdated
| file.write(content) | ||
|
|
||
| app = FileResponse(path=path, filename="example.png") | ||
| client = test_client_factory(app) |
Owner
Author
There was a problem hiding this comment.
This test is actually useless, since the TestClient drops the body on HEAD methods.
I'll create a new test later, but if you want to approve, it will speed up the process here. 👀
adriangb
approved these changes
Dec 10, 2023
iudeen
approved these changes
Dec 10, 2023
32a0c4d to
3e82824
Compare
3 tasks
mvdbeek
added a commit
to galaxybot/galaxy
that referenced
this pull request
Jan 30, 2024
The ``send_header_only`` attribute has been removed in starlette (Kludex/starlette#2366), and replaced with `scope["method"].upper() == "HEAD"`
mvdbeek
added a commit
to galaxybot/galaxy
that referenced
this pull request
Jan 30, 2024
The ``send_header_only`` attribute has been removed in starlette (Kludex/starlette#2366), and replaced with `scope["method"].upper() == "HEAD"`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The server drops the body on
HEADanyway, so even if we don't have this logic at all, the client still receives an empty body.The idea of still having to check the method is to avoid opening the file.