]> git.ipfire.org Git - thirdparty/httpx.git/commitdiff
Drop mode argument, 'httpx.Proxy(..., mode=...)' (#1795)
authorTom Christie <tom@tomchristie.com>
Fri, 13 Aug 2021 10:34:56 +0000 (11:34 +0100)
committerGitHub <noreply@github.com>
Fri, 13 Aug 2021 10:34:56 +0000 (11:34 +0100)
httpx/_config.py
httpx/_transports/default.py
tests/test_config.py

index 9d29f9f2f1e178918275ec26e307e7151dbdfc4a..927a67c2b168d27c98112596222d4ecbde268b3a 100644 (file)
@@ -316,16 +316,12 @@ class Limits:
 
 
 class Proxy:
-    def __init__(
-        self, url: URLTypes, *, headers: HeaderTypes = None, mode: str = "DEFAULT"
-    ):
+    def __init__(self, url: URLTypes, *, headers: HeaderTypes = None):
         url = URL(url)
         headers = Headers(headers)
 
         if url.scheme not in ("http", "https"):
             raise ValueError(f"Unknown scheme for proxy URL {url!r}")
-        if mode not in ("DEFAULT", "FORWARD_ONLY", "TUNNEL_ONLY"):
-            raise ValueError(f"Unknown proxy mode {mode!r}")
 
         if url.username or url.password:
             headers.setdefault(
@@ -338,7 +334,6 @@ class Proxy:
 
         self.url = url
         self.headers = headers
-        self.mode = mode
 
     def _build_auth_header(self, username: str, password: str) -> str:
         userpass = (username.encode("utf-8"), password.encode("utf-8"))
@@ -346,11 +341,7 @@ class Proxy:
         return f"Basic {token}"
 
     def __repr__(self) -> str:
-        return (
-            f"Proxy(url={str(self.url)!r}, "
-            f"headers={dict(self.headers)!r}, "
-            f"mode={self.mode!r})"
-        )
+        return f"Proxy(url={str(self.url)!r}, headers={dict(self.headers)!r})"
 
 
 DEFAULT_TIMEOUT_CONFIG = Timeout(timeout=5.0)
index ae6c2d1777594444340115286fd2ed679598d4bc..73401fce66c8b793acc383307f7279fef1a29c7c 100644 (file)
@@ -145,7 +145,6 @@ class HTTPTransport(BaseTransport):
             self._pool = httpcore.SyncHTTPProxy(
                 proxy_url=proxy.url.raw,
                 proxy_headers=proxy.headers.raw,
-                proxy_mode=proxy.mode,
                 ssl_context=ssl_context,
                 max_connections=limits.max_connections,
                 max_keepalive_connections=limits.max_keepalive_connections,
@@ -242,7 +241,6 @@ class AsyncHTTPTransport(AsyncBaseTransport):
             self._pool = httpcore.AsyncHTTPProxy(
                 proxy_url=proxy.url.raw,
                 proxy_headers=proxy.headers.raw,
-                proxy_mode=proxy.mode,
                 ssl_context=ssl_context,
                 max_connections=limits.max_connections,
                 max_keepalive_connections=limits.max_keepalive_connections,
index f218f8f2082f7024959f2b258590cb3e534e87fa..3a17cf597606401030d8283567a703b0c84bc3b6 100644 (file)
@@ -200,33 +200,26 @@ def test_ssl_config_support_for_keylog_file(tmpdir, monkeypatch):  # pragma: noc
 
 
 @pytest.mark.parametrize(
-    "url,expected_url,expected_headers,expected_mode",
+    "url,expected_url,expected_headers",
     [
-        ("https://example.com", "https://example.com", {}, "DEFAULT"),
+        ("https://example.com", "https://example.com", {}),
         (
             "https://user:pass@example.com",
             "https://example.com",
             {"proxy-authorization": "Basic dXNlcjpwYXNz"},
-            "DEFAULT",
         ),
     ],
 )
-def test_proxy_from_url(url, expected_url, expected_headers, expected_mode):
+def test_proxy_from_url(url, expected_url, expected_headers):
     proxy = httpx.Proxy(url)
 
     assert str(proxy.url) == expected_url
     assert dict(proxy.headers) == expected_headers
-    assert proxy.mode == expected_mode
-    assert repr(proxy) == "Proxy(url='{}', headers={}, mode='{}')".format(
-        expected_url, str(expected_headers), expected_mode
+    assert repr(proxy) == "Proxy(url='{}', headers={})".format(
+        expected_url, str(expected_headers)
     )
 
 
 def test_invalid_proxy_scheme():
     with pytest.raises(ValueError):
         httpx.Proxy("invalid://example.com")
-
-
-def test_invalid_proxy_mode():
-    with pytest.raises(ValueError):
-        httpx.Proxy("https://example.com", mode="INVALID")