Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
URLPattern,
get_ca_bundle_from_env,
get_environment_proxies,
same_origin,
)

from .common import TESTS_DIR
Expand Down Expand Up @@ -224,15 +223,23 @@ def test_obfuscate_sensitive_headers(headers, output):


def test_same_origin():
origin1 = httpx.URL("https://example.com")
origin2 = httpx.URL("HTTPS://EXAMPLE.COM:443")
assert same_origin(origin1, origin2)
origin = httpx.URL("https://example.com")
request = httpx.Request("GET", "HTTPS://EXAMPLE.COM:443")

client = httpx.Client()
headers = client._redirect_headers(request, origin, "GET")

assert headers["Host"] == request.url.netloc.decode("ascii")


def test_not_same_origin():
origin1 = httpx.URL("https://example.com")
origin2 = httpx.URL("HTTP://EXAMPLE.COM")
assert not same_origin(origin1, origin2)
origin = httpx.URL("https://example.com")
request = httpx.Request("GET", "HTTP://EXAMPLE.COM:80")

client = httpx.Client()
headers = client._redirect_headers(request, origin, "GET")

assert headers["Host"] == origin.netloc.decode("ascii")


def test_is_https_redirect():
Expand Down