Add support for the QUERY HTTP method#3370
Open
Kfir-G wants to merge 2 commits into
Open
Conversation
|
TestClient needs a query function that follows the same pattern as the other methods and inherits from Httpx2 Client which support for query was added a day ago.
However the issue, starlette's Line 73 in 5174d4c I don't think the maintainers will want to reduce the restriction so this might sit for a few days until that window expires. |
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.
Summary
Adds support for the
QUERYHTTP method (draft spec: https://http.dev/query). Follow-up to the discussion here: [link to your discussion].Routing itself already worked with no changes, since
Route/Routerdon't hardcode a fixed list of HTTP verbs -Route("/search", search, methods=["QUERY"])already works today. The actual changes needed were small:starlette/endpoints.py- added"QUERY"to the verbsHTTPEndpointchecks when building_allowed_methods, so a.query()handler on a class-based endpoint is recognized (and shows up correctly in theAllowheader on 405 responses).starlette/schemas.py- added"query"to the method listSchemaGeneratorchecks on class-based endpoints, so.query()handlers are picked up in generated OpenAPI schemas.docs/routing.mdanddocs/endpoints.md- short additions showingQUERYas a supported method.This is purely additive -
QUERYis only reachable if a route explicitly opts in viamethods=[...], same as any other verb, so it shouldn't interact with the recentHTTPEndpointdispatch advisory (GHSA-x746-7m8f-x49c).Ran
scripts/checkandscripts/testlocally - all passing, 100% coverage maintained.This is my first PR here, so happy to adjust based on feedback or conventions I'm missing.
Checklist