From a54ecccd5b7e61b29ec13df45ecc0b82a2c168bb Mon Sep 17 00:00:00 2001 From: Kar Petrosyan <92274156+karosis88@users.noreply.github.com> Date: Mon, 11 Sep 2023 05:56:01 -0400 Subject: [PATCH] HTTPS proxies support (#2845) * Add ssl_context argument to Proxy class * Changelog --- CHANGELOG.md | 1 + httpx/_config.py | 2 ++ httpx/_transports/default.py | 1 + 3 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fc53394a7..5a6d927409 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +* Support HTTPS proxies. (#2845) * Change the type of `Extensions` from `Mapping[Str, Any]` to `MutableMapping[Str, Any]`. (#2803) * Add `socket_options` argument to `httpx.HTTPTransport` and `httpx.AsyncHTTPTransport` classes. (#2716) * The `Response.raise_for_status()` method now returns the response instance. For example: `data = httpx.get('...').raise_for_status().json()`. (#2776) diff --git a/httpx/_config.py b/httpx/_config.py index f46a5bfe6b..39d81a20a0 100644 --- a/httpx/_config.py +++ b/httpx/_config.py @@ -326,6 +326,7 @@ def __init__( self, url: URLTypes, *, + ssl_context: typing.Optional[ssl.SSLContext] = None, auth: typing.Optional[typing.Tuple[str, str]] = None, headers: typing.Optional[HeaderTypes] = None, ): @@ -343,6 +344,7 @@ def __init__( self.url = url self.auth = auth self.headers = headers + self.ssl_context = ssl_context @property def raw_auth(self) -> typing.Optional[typing.Tuple[bytes, bytes]]: diff --git a/httpx/_transports/default.py b/httpx/_transports/default.py index 1aebd5c5a5..7dba5b8208 100644 --- a/httpx/_transports/default.py +++ b/httpx/_transports/default.py @@ -156,6 +156,7 @@ def __init__( proxy_auth=proxy.raw_auth, proxy_headers=proxy.headers.raw, ssl_context=ssl_context, + proxy_ssl_context=proxy.ssl_context, max_connections=limits.max_connections, max_keepalive_connections=limits.max_keepalive_connections, keepalive_expiry=limits.keepalive_expiry,