diff --git a/locust/clients.py b/locust/clients.py index 56c5396357..a798725c6a 100644 --- a/locust/clients.py +++ b/locust/clients.py @@ -8,7 +8,7 @@ from requests.exceptions import (InvalidSchema, InvalidURL, MissingSchema, RequestException) -from six.moves.urllib.parse import urlparse, urlunparse +from six.moves.urllib.parse import urlparse, urlunparse, urljoin from . import events from .exception import CatchResponseError, ResponseError @@ -69,8 +69,8 @@ def _build_url(self, path): if absolute_http_url_regexp.match(path): return path else: - return "%s%s" % (self.base_url, path) - + return urljoin(self.base_url, path) + def request(self, method, url, name=None, catch_response=False, **kwargs): """ Constructs and sends a :py:class:`requests.Request`. diff --git a/locust/test/test_client.py b/locust/test/test_client.py index afd2da6cd7..d8b6864988 100644 --- a/locust/test/test_client.py +++ b/locust/test/test_client.py @@ -23,8 +23,8 @@ def test_connection_error(self): def test_wrong_url(self): for url, exception in ( (u"http://\x94", InvalidURL), - ("telnet://127.0.0.1", InvalidSchema), - ("127.0.0.1", MissingSchema), + ("telnet://127.0.0.1", MissingSchema), + ("127.0.0.1", MissingSchema), ): s = HttpSession(url) try: