Allow for custom head method in HTTPEndpoint#1222
Closed
theblazehen wants to merge 3 commits intoKludex:masterfrom
Closed
Allow for custom head method in HTTPEndpoint#1222theblazehen wants to merge 3 commits intoKludex:masterfrom
theblazehen wants to merge 3 commits intoKludex:masterfrom
Conversation
aminalaee
reviewed
Jun 28, 2021
|
|
||
| if request.method == "HEAD": | ||
| if hasattr(self, "head"): | ||
| handler_name = "head" |
Contributor
There was a problem hiding this comment.
Do you have test coverage for this?
Contributor
Author
There was a problem hiding this comment.
No. In which file would the relevant tests be?
Contributor
There was a problem hiding this comment.
Not really sure, maybe tests/test_endpoints.py. Or any other places using HTTPEndpoint
aminalaee
reviewed
Jun 28, 2021
| request = Request(self.scope, receive=self.receive) | ||
| handler_name = "get" if request.method == "HEAD" else request.method.lower() | ||
|
|
||
| if request.method == "HEAD": |
Contributor
There was a problem hiding this comment.
It's safer to check request.method.lower() == "head"
Kludex
requested changes
Sep 25, 2021
Owner
Kludex
left a comment
There was a problem hiding this comment.
@theblazehen Thanks for the PR! 🎉
Can you rebase it and check my comment?
Comment on lines
+26
to
+34
|
|
||
| if request.method == "HEAD": | ||
| if hasattr(self, "head"): | ||
| handler_name = "head" | ||
| else: | ||
| handler_name = "get" | ||
| else: | ||
| handler_name = request.method.lower() | ||
|
|
Owner
There was a problem hiding this comment.
We just need to add the not hasattr(self, "head") logic.
Suggested change
| if request.method == "HEAD": | |
| if hasattr(self, "head"): | |
| handler_name = "head" | |
| else: | |
| handler_name = "get" | |
| else: | |
| handler_name = request.method.lower() | |
| handler_name = ( | |
| "get" | |
| if request.method == "HEAD" and not hasattr(self, "head") | |
| else request.method.lower() | |
| ) |
Owner
|
@theblazehen Do you wish to resume your work? Otherwise, I'll be closing as stale 😗 |
Owner
|
Close in favor of #1346 |
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.
Fix for #1221