From e93c23932832a4632154fd01499712e5cf56c51c Mon Sep 17 00:00:00 2001 From: Lyonnet Date: Thu, 10 Oct 2024 17:21:04 +0800 Subject: [PATCH] Add shortcut for TRACE and QUERY(https://httpwg.org/http-extensions/draft-ietf-httpbis-safe-method-w-body.html) --- curl_cffi/requests/__init__.py | 2 ++ curl_cffi/requests/session.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/curl_cffi/requests/__init__.py b/curl_cffi/requests/__init__.py index 804dbe0..41deb97 100644 --- a/curl_cffi/requests/__init__.py +++ b/curl_cffi/requests/__init__.py @@ -173,3 +173,5 @@ def request( patch = partial(request, "PATCH") delete = partial(request, "DELETE") options = partial(request, "OPTIONS") +trace = partial(request, "TRACE") +query = partial(request, "QUERY") diff --git a/curl_cffi/requests/session.py b/curl_cffi/requests/session.py index 3130220..9edbcef 100644 --- a/curl_cffi/requests/session.py +++ b/curl_cffi/requests/session.py @@ -94,7 +94,7 @@ class BaseSessionParams(TypedDict, total=False): BaseSessionParams = TypedDict ThreadType = Literal["eventlet", "gevent"] -HttpMethod = Literal["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "TRACE", "PATCH"] +HttpMethod = Literal["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "TRACE", "PATCH", "QUERY"] def _is_absolute_url(url: str) -> bool: @@ -1080,6 +1080,8 @@ def cleanup(fut): patch = partialmethod(request, "PATCH") delete = partialmethod(request, "DELETE") options = partialmethod(request, "OPTIONS") + trace = partialmethod(request, "TRACE") + query = partialmethod(request, "QUERY") class AsyncSession(BaseSession): @@ -1364,3 +1366,5 @@ def cleanup(fut): patch = partialmethod(request, "PATCH") delete = partialmethod(request, "DELETE") options = partialmethod(request, "OPTIONS") + trace = partialmethod(request, "TRACE") + query = partialmethod(request, "QUERY")