-
-
Notifications
You must be signed in to change notification settings - Fork 959
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
Deprecate FileResponse(method=...)
parameter
#2366
Conversation
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.", |
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.
The method
parameter becomes a no-op with this PR, and it's "scheduled" to be removed in 1.0.
tests/test_responses.py
Outdated
file.write(content) | ||
|
||
app = FileResponse(path=path, filename="example.png") | ||
client = test_client_factory(app) |
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.
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. 👀
32a0c4d
to
3e82824
Compare
The ``send_header_only`` attribute has been removed in starlette (encode/starlette#2366), and replaced with `scope["method"].upper() == "HEAD"`
The ``send_header_only`` attribute has been removed in starlette (encode/starlette#2366), and replaced with `scope["method"].upper() == "HEAD"`
The server drops the body on
HEAD
anyway, 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.