From 751c692e6affaf0c8951b3ba594a375f5702e1fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 Aug 2016 14:34:15 +0200 Subject: [PATCH] Use urlparse.urlunsplit() to join url parts together. This also works when there is no scheme and no hostname. --- pillar/sdk.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pillar/sdk.py b/pillar/sdk.py index 28b8e1dd..47017e7b 100644 --- a/pillar/sdk.py +++ b/pillar/sdk.py @@ -21,11 +21,12 @@ class FlaskInternalApi(pillarsdk.Api): """Fakes a http call through Flask/Werkzeug.""" client = current_app.test_client() self.requests_to_flask_kwargs(kwargs) - url = urlparse.urlsplit(url) - path = url.scheme + "://" + url.netloc + url.path - query = url.query + + # Leave out the query string and fragment from the URL. + split_url = urlparse.urlsplit(url) + path = urlparse.urlunsplit(split_url[:-2] + (None, None)) try: - response = client.open(path=path, query_string=query, method=method, + response = client.open(path=path, query_string=split_url.query, method=method, **kwargs) except Exception as ex: log.warning('Error performing HTTP %s request to %s: %s', method,