]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Add client.request
authorTom Christie <tom@tomchristie.com>
Mon, 22 Apr 2019 21:12:46 +0000 (22:12 +0100)
committerTom Christie <tom@tomchristie.com>
Mon, 22 Apr 2019 21:12:46 +0000 (22:12 +0100)
httpcore/connections.py
httpcore/datastructures.py
httpcore/pool.py

index dadcfd90cb1e4f278042aea04a4bc8078aa00d41..c9b695730ddfca78c13d700377379e726607ede3 100644 (file)
@@ -40,6 +40,7 @@ class Connection:
     async def send(
         self,
         request: Request,
+        *,
         ssl: typing.Optional[SSLConfig] = None,
         timeout: typing.Optional[TimeoutConfig] = None,
         stream: bool = False,
index d6cadc422ad4c0dc81b8ff0f420a0831e442e76f..09c288bc2fa07afb6c85a5d1303fa7362460b1d4 100644 (file)
@@ -2,6 +2,7 @@ import http
 import typing
 from urllib.parse import urlsplit
 
+from .config import SSLConfig, TimeoutConfig
 from .decoders import (
     ACCEPT_ENCODING,
     SUPPORTED_DECODERS,
@@ -238,7 +239,28 @@ class Response:
 
 
 class Client:
-    async def send(self, request: Request, **options: typing.Any) -> Response:
+    async def request(
+        self,
+        method: str,
+        url: typing.Union[str, URL],
+        *,
+        headers: typing.Sequence[typing.Tuple[bytes, bytes]] = (),
+        body: typing.Union[bytes, typing.AsyncIterator[bytes]] = b"",
+        ssl: typing.Optional[SSLConfig] = None,
+        timeout: typing.Optional[TimeoutConfig] = None,
+        stream: bool = False,
+    ) -> Response:
+        request = Request(method, url, headers=headers, body=body)
+        return await self.send(request, ssl=ssl, timeout=timeout, stream=stream)
+
+    async def send(
+        self,
+        request: Request,
+        *,
+        ssl: typing.Optional[SSLConfig] = None,
+        timeout: typing.Optional[TimeoutConfig] = None,
+        stream: bool = False,
+    ) -> Response:
         raise NotImplementedError()  # pragma: nocover
 
     async def close(self) -> None:
index 1a8466288667206665f0b3df2ce4fea6017fbf64..3f9ecd70213914dfe2620a10773a543dbbd67053 100644 (file)
@@ -54,6 +54,7 @@ class ConnectionPool:
     async def send(
         self,
         request: Request,
+        *,
         ssl: typing.Optional[SSLConfig] = None,
         timeout: typing.Optional[TimeoutConfig] = None,
         stream: bool = False,