From: Jérémy Bethmont Date: Wed, 17 Aug 2011 08:07:43 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/develop' into develop X-Git-Tag: v0.6.1~3^2~3^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe109b27be1fcafee5d33924d9b84f47ba173264;p=services%2Fpython-requests.git Merge remote-tracking branch 'upstream/develop' into develop Conflicts: requests/models.py --- fe109b27be1fcafee5d33924d9b84f47ba173264 diff --cc requests/models.py index a5b641d,5e54f37..0d7b67c --- a/requests/models.py +++ b/requests/models.py @@@ -20,7 -20,8 +20,8 @@@ from .monkeys import Request as _Reques from .structures import CaseInsensitiveDict from .packages.poster.encode import multipart_encode from .packages.poster.streaminghttp import register_openers, get_handlers + from .utils import dict_from_cookiejar -from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod +from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod, TooManyRedirects REDIRECT_STATI = (301, 302, 303, 307) @@@ -169,8 -187,13 +187,14 @@@ class Request(object) try: response.headers = CaseInsensitiveDict(getattr(resp.info(), 'dict', None)) response.read = resp.read - response.close = resp.close + response._resp = resp + response._close = resp.close + + if self.cookiejar: + + response.cookies = dict_from_cookiejar(self.cookiejar) + + except AttributeError: pass @@@ -203,8 -224,7 +230,7 @@@ # Facilitate non-RFC2616-compliant 'location' headers # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource') - if not urlparse(url).netloc: - url = urljoin(r.url, urllib.quote(urllib.unquote(url))) - url = urljoin(r.url, 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: @@@ -249,15 -270,12 +276,15 @@@ def _build_url(self): - """Build the actual URL to use""" + """Build the actual URL to use.""" - # Support for unicode domain names. - parsed_url = list(urlparse(self.url)) - parsed_url[1] = parsed_url[1].encode('idna') - self.url = urlunparse(parsed_url) + # Support for unicode domain names and paths. + scheme, netloc, path, params, query, fragment = urlparse(self.url) + netloc = netloc.encode('idna') + if isinstance(path, unicode): + path = path.encode('utf-8') + path = urllib.quote(urllib.unquote(path)) + self.url = str(urlunparse([ scheme, netloc, path, params, query, fragment ])) if self._enc_params: if urlparse(self.url).query: