URLPattern,
get_ca_bundle_from_env,
get_environment_proxies,
- is_https_redirect,
same_origin,
)
def test_is_https_redirect():
- url = httpx.URL("http://example.com")
- location = httpx.URL("https://example.com")
- assert is_https_redirect(url, location)
+ url = httpx.URL("https://example.com")
+ request = httpx.Request(
+ "GET", "http://example.com", headers={"Authorization": "empty"}
+ )
+
+ client = httpx.Client()
+ headers = client._redirect_headers(request, url, "GET")
+
+ assert "Authorization" in headers
def test_is_not_https_redirect():
- url = httpx.URL("http://example.com")
- location = httpx.URL("https://www.example.com")
- assert not is_https_redirect(url, location)
+ url = httpx.URL("https://www.example.com")
+ request = httpx.Request(
+ "GET", "http://example.com", headers={"Authorization": "empty"}
+ )
+
+ client = httpx.Client()
+ headers = client._redirect_headers(request, url, "GET")
+
+ assert "Authorization" not in headers
def test_is_not_https_redirect_if_not_default_ports():
- url = httpx.URL("http://example.com:9999")
- location = httpx.URL("https://example.com:1337")
- assert not is_https_redirect(url, location)
+ url = httpx.URL("https://example.com:1337")
+ request = httpx.Request(
+ "GET", "http://example.com:9999", headers={"Authorization": "empty"}
+ )
+
+ client = httpx.Client()
+ headers = client._redirect_headers(request, url, "GET")
+
+ assert "Authorization" not in headers
@pytest.mark.parametrize(