]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Updates for httpcore 0.9 interface. (#967)
authorTom Christie <tom@tomchristie.com>
Thu, 21 May 2020 12:21:43 +0000 (13:21 +0100)
committerGitHub <noreply@github.com>
Thu, 21 May 2020 12:21:43 +0000 (13:21 +0100)
* Pass proxy_url

* Update httpcore dependancy

* Update port in Transport API to be 'Optional[int]'

httpx/_client.py
httpx/_transports/asgi.py
httpx/_transports/urllib3.py
httpx/_transports/wsgi.py
setup.py

index 3464fa3b9e5e551aae35c07caeaffba633de564c..8c3e47fda60dc5445785db540c3a73816c6a6b58 100644 (file)
@@ -528,7 +528,7 @@ class Client(BaseClient):
         max_connections = pool_limits.hard_limit
 
         return httpcore.SyncHTTPProxy(
-            proxy_origin=proxy.url.raw[:3],
+            proxy_url=proxy.url.raw,
             proxy_headers=proxy.headers.raw,
             proxy_mode=proxy.mode,
             ssl_context=ssl_context,
@@ -1076,7 +1076,7 @@ class AsyncClient(BaseClient):
         max_connections = pool_limits.hard_limit
 
         return httpcore.AsyncHTTPProxy(
-            proxy_origin=proxy.url.raw[:3],
+            proxy_url=proxy.url.raw,
             proxy_headers=proxy.headers.raw,
             proxy_mode=proxy.mode,
             ssl_context=ssl_context,
index d53bf0e53d55d2c7658f76d8d57aa3abedb7d3b3..937c7cc0065c458635aaf0a21c70bd7e1abe9432 100644 (file)
@@ -73,7 +73,7 @@ class ASGITransport(httpcore.AsyncHTTPTransport):
     async def request(
         self,
         method: bytes,
-        url: Tuple[bytes, bytes, int, bytes],
+        url: Tuple[bytes, bytes, Optional[int], bytes],
         headers: List[Tuple[bytes, bytes]] = None,
         stream: httpcore.AsyncByteStream = None,
         timeout: Dict[str, Optional[float]] = None,
index 0156af8b2659d258ea6dd8045a24a18828b08761..71882e117884f8dd374a3a1dc4f764a653e56dac 100644 (file)
@@ -88,7 +88,7 @@ class URLLib3Transport(httpcore.SyncHTTPTransport):
     def request(
         self,
         method: bytes,
-        url: Tuple[bytes, bytes, int, bytes],
+        url: Tuple[bytes, bytes, Optional[int], bytes],
         headers: List[Tuple[bytes, bytes]] = None,
         stream: httpcore.SyncByteStream = None,
         timeout: Dict[str, Optional[float]] = None,
@@ -112,8 +112,8 @@ class URLLib3Transport(httpcore.SyncHTTPTransport):
         body = stream if chunked or content_length else None
 
         scheme, host, port, path = url
-        default_scheme = {80: b"http", 443: "https"}.get(port)
-        if scheme == default_scheme:
+        default_port = {b"http": 80, "https": 443}.get(scheme)
+        if port is None or port == default_port:
             url_str = "%s://%s%s" % (
                 scheme.decode("ascii"),
                 host.decode("ascii"),
index 7036d312be557ed62f5b4896e5de151b5925070d..78f2da77d934c996c3c97751c44262440b650a66 100644 (file)
@@ -64,7 +64,7 @@ class WSGITransport(httpcore.SyncHTTPTransport):
     def request(
         self,
         method: bytes,
-        url: typing.Tuple[bytes, bytes, int, bytes],
+        url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],
         headers: typing.List[typing.Tuple[bytes, bytes]] = None,
         stream: httpcore.SyncByteStream = None,
         timeout: typing.Dict[str, typing.Optional[float]] = None,
index 4fe7e1bed277343aaa69719637b2eff501ebfb0d..cc6216992c132f2c398c487d3aa71456d02858c3 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -61,7 +61,7 @@ setup(
         "chardet==3.*",
         "idna==2.*",
         "rfc3986>=1.3,<2",
-        "httpcore>=0.8.4",
+        "httpcore==0.9.*",
     ],
     classifiers=[
         "Development Status :: 4 - Beta",