Skip to content

Commit

Permalink
Raise exception when proxy_ssl_context used with the http scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
karpetrosyan committed Sep 1, 2023
1 parent bee1738 commit 68d0653
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion httpcore/_async/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ def __init__(
uds=uds,
socket_options=socket_options,
)

self._proxy_url = enforce_url(proxy_url, name="proxy_url")
if (
self._proxy_url.scheme == b"http" and proxy_ssl_context is not None
): # pragma: no cover
raise RuntimeError(
"The `proxy_ssl_context` argument is not allowed for the http scheme"
)

self._ssl_context = ssl_context
self._proxy_ssl_context = proxy_ssl_context
self._proxy_url = enforce_url(proxy_url, name="proxy_url")
self._proxy_headers = enforce_headers(proxy_headers, name="proxy_headers")
if proxy_auth is not None:
username = enforce_bytes(proxy_auth[0], name="proxy_auth")
Expand Down
10 changes: 9 additions & 1 deletion httpcore/_sync/http_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,17 @@ def __init__(
uds=uds,
socket_options=socket_options,
)

self._proxy_url = enforce_url(proxy_url, name="proxy_url")
if (
self._proxy_url.scheme == b"http" and proxy_ssl_context is not None
): # pragma: no cover
raise RuntimeError(
"The `proxy_ssl_context` argument is not allowed for the http scheme"
)

self._ssl_context = ssl_context
self._proxy_ssl_context = proxy_ssl_context
self._proxy_url = enforce_url(proxy_url, name="proxy_url")
self._proxy_headers = enforce_headers(proxy_headers, name="proxy_headers")
if proxy_auth is not None:
username = enforce_bytes(proxy_auth[0], name="proxy_auth")
Expand Down

0 comments on commit 68d0653

Please sign in to comment.