From: Jérémy Bethmont Date: Tue, 9 Aug 2011 13:41:59 +0000 (+0200) Subject: Use urljoin instead of manual concatenation. X-Git-Tag: v0.6.1~3^2~3^2~6^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b79cea7384a2dd3df90ac748bac3c4a89ebce24;p=services%2Fpython-requests.git Use urljoin instead of manual concatenation. --- diff --git a/requests/models.py b/requests/models.py index 5110029..57ee5dd 100644 --- a/requests/models.py +++ b/requests/models.py @@ -12,7 +12,7 @@ import socket import zlib from urllib2 import HTTPError -from urlparse import urlparse, urlunparse +from urlparse import urlparse, urlunparse, urljoin from datetime import datetime from .config import settings @@ -198,8 +198,7 @@ class Request(object): # Facilitate non-RFC2616-compliant 'location' headers # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource') if not urlparse(url).netloc: - parent_url_components = urlparse(self.url) - url = '%s://%s/%s' % (parent_url_components.scheme, parent_url_components.netloc, urllib.quote(urllib.unquote(url))) + url = urljoin(r.url, urllib.quote(urllib.unquote(url))) # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4 if r.status_code is 303: