def test_merge_absolute_url():
client = httpx.Client(base_url="https://www.example.com/")
request = client.build_request("GET", "http://www.example.com/")
- assert request.url == httpx.URL("http://www.example.com/")
+ assert request.url == "http://www.example.com/"
with pytest.warns(DeprecationWarning):
assert not request.url.is_ssl
def test_merge_relative_url():
client = httpx.Client(base_url="https://www.example.com/")
request = client.build_request("GET", "/testing/123")
- assert request.url == httpx.URL("https://www.example.com/testing/123")
+ assert request.url == "https://www.example.com/testing/123"
def test_merge_relative_url_with_path():
client = httpx.Client(base_url="https://www.example.com/some/path")
request = client.build_request("GET", "/testing/123")
- assert request.url == httpx.URL("https://www.example.com/some/path/testing/123")
+ assert request.url == "https://www.example.com/some/path/testing/123"
def test_merge_relative_url_with_dotted_path():
client = httpx.Client(base_url="https://www.example.com/some/path")
request = client.build_request("GET", "../testing/123")
- assert request.url == httpx.URL("https://www.example.com/some/testing/123")
+ assert request.url == "https://www.example.com/some/testing/123"
def test_pool_limits_deprecated():
client = httpx.Client(transport=SyncMockTransport())
response = client.post("https://example.org/redirect_301")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.post("https://example.org/redirect_302")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.get("https://example.org/redirect_303")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.post("https://example.org/redirect_303", allow_redirects=False)
assert response.status_code == httpx.codes.SEE_OTHER
- assert response.url == httpx.URL("https://example.org/redirect_303")
+ assert response.url == "https://example.org/redirect_303"
assert response.is_redirect is True
assert len(response.history) == 0
response = response.next()
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert response.is_redirect is False
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.head("https://example.org/redirect_302")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert response.request.method == "HEAD"
assert len(response.history) == 1
assert response.text == ""
client = httpx.Client(transport=SyncMockTransport())
response = client.get("https://example.org/relative_redirect")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.get("http://example.org/malformed_redirect")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org:443/")
+ assert response.url == "https://example.org:443/"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.get("https://example.org/no_scheme_redirect")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/")
+ assert response.url == "https://example.org/"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.get("https://example.org/relative_redirect#fragment")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/#fragment")
+ assert response.url == "https://example.org/#fragment"
assert len(response.history) == 1
client = httpx.Client(transport=SyncMockTransport())
response = client.get("https://example.org/multiple_redirects?count=20")
assert response.status_code == httpx.codes.OK
- assert response.url == httpx.URL("https://example.org/multiple_redirects")
+ assert response.url == "https://example.org/multiple_redirects"
assert len(response.history) == 20
- assert response.history[0].url == httpx.URL(
- "https://example.org/multiple_redirects?count=20"
- )
- assert response.history[1].url == httpx.URL(
- "https://example.org/multiple_redirects?count=19"
- )
+ assert response.history[0].url == "https://example.org/multiple_redirects?count=20"
+ assert response.history[1].url == "https://example.org/multiple_redirects?count=19"
assert len(response.history[0].history) == 0
assert len(response.history[1].history) == 1
url = "https://example.com/cross_domain"
headers = {"Authorization": "abc"}
response = client.get(url, headers=headers)
- assert response.url == httpx.URL("https://example.org/cross_domain_target")
+ assert response.url == "https://example.org/cross_domain_target"
assert "authorization" not in response.json()["headers"]
url = "https://example.org/cross_domain"
headers = {"Authorization": "abc"}
response = client.get(url, headers=headers)
- assert response.url == httpx.URL("https://example.org/cross_domain_target")
+ assert response.url == "https://example.org/cross_domain_target"
assert response.json()["headers"]["authorization"] == "abc"
url = "https://example.org/redirect_body"
data = b"Example request body"
response = client.post(url, data=data)
- assert response.url == httpx.URL("https://example.org/redirect_body_target")
+ assert response.url == "https://example.org/redirect_body_target"
assert response.json()["body"] == "Example request body"
assert "content-length" in response.json()["headers"]
url = "https://example.org/redirect_no_body"
data = b"Example request body"
response = client.post(url, data=data)
- assert response.url == httpx.URL("https://example.org/redirect_body_target")
+ assert response.url == "https://example.org/redirect_body_target"
assert response.json()["body"] == ""
assert "content-length" not in response.json()["headers"]
client = httpx.Client(transport=SyncMockTransport())
url = "https://example.com/cross_subdomain"
response = client.get(url)
- assert response.url == httpx.URL("https://www.example.org/cross_subdomain")
+ assert response.url == "https://www.example.org/cross_subdomain"
class MockCookieTransport(httpcore.SyncHTTPTransport):