diff --git a/curl_cffi/requests/__init__.py b/curl_cffi/requests/__init__.py index c37b51f..3f66a77 100644 --- a/curl_cffi/requests/__init__.py +++ b/curl_cffi/requests/__init__.py @@ -37,12 +37,12 @@ from .headers import Headers, HeaderTypes from .impersonate import BrowserType, BrowserTypeLiteral, ExtraFingerprints, ExtraFpDict from .models import Request, Response -from .session import AsyncSession, ProxySpec, Session, ThreadType +from .session import AsyncSession, HttpMethod, ProxySpec, Session, ThreadType from .websockets import WebSocket, WebSocketError, WsCloseCode def request( - method: str, + method: HttpMethod, url: str, params: Optional[Union[Dict, List, Tuple]] = None, data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None, diff --git a/curl_cffi/requests/session.py b/curl_cffi/requests/session.py index 18f0e76..1d5333d 100644 --- a/curl_cffi/requests/session.py +++ b/curl_cffi/requests/session.py @@ -92,6 +92,7 @@ class BaseSessionParams(TypedDict, total=False): BaseSessionParams = TypedDict ThreadType = Literal["eventlet", "gevent"] +HttpMethod = Literal["GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD", "TRACE"] def _is_absolute_url(url: str) -> bool: @@ -346,7 +347,7 @@ def _set_extra_fp(self, curl, fp: ExtraFingerprints): def _set_curl_options( self, curl, - method: str, + method: HttpMethod, url: str, params: Optional[Union[Dict, List, Tuple]] = None, data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None, @@ -888,7 +889,7 @@ def ws_connect( def request( self, - method: str, + method: HttpMethod, url: str, params: Optional[Union[Dict, List, Tuple]] = None, data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None, @@ -1180,7 +1181,7 @@ async def ws_connect(self, url, *args, **kwargs): async def request( self, - method: str, + method: HttpMethod, url: str, params: Optional[Union[Dict, List, Tuple]] = None, data: Optional[Union[Dict[str, str], List[Tuple], str, BytesIO, bytes]] = None,