From 6456b2b2fb2cfe06d1d23e1d4a08682e9e2f9a64 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 5 Aug 2020 14:39:12 +0100 Subject: [PATCH 1/2] URL.join(url=...), not URL.join(relative_url=...) --- httpx/_client.py | 2 +- httpx/_models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/httpx/_client.py b/httpx/_client.py index dad4a42aab..0a2e525a2f 100644 --- a/httpx/_client.py +++ b/httpx/_client.py @@ -208,7 +208,7 @@ def _merge_url(self, url: URLTypes) -> URL: Merge a URL argument together with any 'base_url' on the client, to create the URL used for the outgoing request. """ - return self.base_url.join(relative_url=url) + return self.base_url.join(url) def _merge_cookies( self, cookies: CookieTypes = None diff --git a/httpx/_models.py b/httpx/_models.py index 9c5aa1773a..ee52111d53 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -183,7 +183,7 @@ def copy_with(self, **kwargs: typing.Any) -> "URL": return URL(self._uri_reference.copy_with(**kwargs).unsplit(),) - def join(self, relative_url: URLTypes) -> "URL": + def join(self, url: URLTypes) -> "URL": """ Return an absolute URL, using given this URL as the base. """ From 8c532d4cef0727f0668441744d7d57cdc38a286f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 5 Aug 2020 14:42:23 +0100 Subject: [PATCH 2/2] Fix URL.join() --- httpx/_models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpx/_models.py b/httpx/_models.py index ee52111d53..41c7a274e6 100644 --- a/httpx/_models.py +++ b/httpx/_models.py @@ -188,12 +188,12 @@ def join(self, url: URLTypes) -> "URL": Return an absolute URL, using given this URL as the base. """ if self.is_relative_url: - return URL(relative_url) + return URL(url) # We drop any fragment portion, because RFC 3986 strictly # treats URLs with a fragment portion as not being absolute URLs. base_uri = self._uri_reference.copy_with(fragment=None) - relative_url = URL(relative_url) + relative_url = URL(url) return URL(relative_url._uri_reference.resolve_with(base_uri).unsplit()) def __hash__(self) -> int: