Skip to content
Myr

Fixes correct "relative" redirections. Example: http://digg.com/d1qIwX, which redirects to "/news/story/A_Manifesto_How_to_Save_Media", which requests transforms to: http://digg.com//news/story/A_Manifesto_How_to_Save_Media" which results in an endless redirect loop.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Jeremy Selier · committed by Jeremy Selier · parent 1cdd1d0 · Browse files · 1 file+2 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+2 added−4 removed

  • other:+2 added−4 removed

1 file+2 added−4 removed

modified:requests/models.py+2 added-4 removed
10 unmodified lines
11import socket12import zlib1314from urllib2 import HTTPError15from urlparse import urlparse, urlunparse15from urlparse import urlparse, urlunparse, urljoin16from datetime import datetime1718from .config import settings19from .monkeys import Request as _Request, HTTPBasicAuthHandler, HTTPForcedBasicAuthHandler, HTTPDigestAuthHandler, HTTPRedirectHandler
176 unmodified lines
196 url = r.headers['location']197198 # Facilitate non-RFC2616-compliant 'location' headers199 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')200 if not urlparse(url).netloc:201 parent_url_components = urlparse(self.url)202 url = '%s://%s/%s' % (parent_url_components.scheme, parent_url_components.netloc, url)200 url = urljoin(self.url, url)201202 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4203 if r.status_code is 303:204 method = 'GET'
360 unmodified lines