From 2d8ec7713c7e846984c34e1468c20c14dc76db76 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 21 May 2020 12:13:20 +0100 Subject: [PATCH 1/3] Pass proxy_url --- httpx/_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpx/_client.py b/httpx/_client.py index a9fee25397..4788bf1511 100644 --- a/httpx/_client.py +++ b/httpx/_client.py @@ -517,7 +517,7 @@ def init_proxy_dispatch( 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, @@ -1055,7 +1055,7 @@ def init_proxy_dispatch( 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, From 7bf8da772e1c95d0ac9ef2111b7593f83e75ff48 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 21 May 2020 13:04:17 +0100 Subject: [PATCH 2/3] Update httpcore dependancy --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4fe7e1bed2..cc6216992c 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ def get_packages(package): "chardet==3.*", "idna==2.*", "rfc3986>=1.3,<2", - "httpcore>=0.8.4", + "httpcore==0.9.*", ], classifiers=[ "Development Status :: 4 - Beta", From b0a1b3bcbe107e111c43693d00caeacfc22f4a8c Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 21 May 2020 13:10:01 +0100 Subject: [PATCH 3/3] Update port in Transport API to be 'Optional[int]' --- httpx/_dispatch/asgi.py | 2 +- httpx/_dispatch/urllib3.py | 6 +++--- httpx/_dispatch/wsgi.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/httpx/_dispatch/asgi.py b/httpx/_dispatch/asgi.py index a86969bcca..03e1b840cb 100644 --- a/httpx/_dispatch/asgi.py +++ b/httpx/_dispatch/asgi.py @@ -72,7 +72,7 @@ def __init__( 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/_dispatch/urllib3.py b/httpx/_dispatch/urllib3.py index 57c257dfa6..7ab88b9c17 100644 --- a/httpx/_dispatch/urllib3.py +++ b/httpx/_dispatch/urllib3.py @@ -80,7 +80,7 @@ def init_pool_manager( 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, @@ -104,8 +104,8 @@ def request( 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/_dispatch/wsgi.py b/httpx/_dispatch/wsgi.py index 9d83183fce..b9af9c40ea 100644 --- a/httpx/_dispatch/wsgi.py +++ b/httpx/_dispatch/wsgi.py @@ -63,7 +63,7 @@ def __init__( 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,