From: Tom Christie Date: Thu, 21 May 2020 12:21:43 +0000 (+0100) Subject: Updates for httpcore 0.9 interface. (#967) X-Git-Tag: 0.13.0~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b6605c3d519142db7ebaf56c13094bf779c7dea;p=thirdparty%2Fhttpx.git Updates for httpcore 0.9 interface. (#967) * Pass proxy_url * Update httpcore dependancy * Update port in Transport API to be 'Optional[int]' --- diff --git a/httpx/_client.py b/httpx/_client.py index 3464fa3b..8c3e47fd 100644 --- a/httpx/_client.py +++ b/httpx/_client.py @@ -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, diff --git a/httpx/_transports/asgi.py b/httpx/_transports/asgi.py index d53bf0e5..937c7cc0 100644 --- a/httpx/_transports/asgi.py +++ b/httpx/_transports/asgi.py @@ -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, diff --git a/httpx/_transports/urllib3.py b/httpx/_transports/urllib3.py index 0156af8b..71882e11 100644 --- a/httpx/_transports/urllib3.py +++ b/httpx/_transports/urllib3.py @@ -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"), diff --git a/httpx/_transports/wsgi.py b/httpx/_transports/wsgi.py index 7036d312..78f2da77 100644 --- a/httpx/_transports/wsgi.py +++ b/httpx/_transports/wsgi.py @@ -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, diff --git a/setup.py b/setup.py index 4fe7e1be..cc621699 100644 --- 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",