Skip to content
Myr

Merge branch 'feature/jerem' into develop

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parents ce4927e, abc5e27 · Browse files · 4 files+37 added−11 removed
This commit

State

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

Diff stats

4 files+37 added−11 removed

  • other:+37 added−11 removed

4 files+37 added−11 removed

modified:requests/config.py+1 added
59 unmodified lines
60settings.accept_gzip = True61settings.proxies = None62settings.verbose = None63settings.timeout = None64settings.max_redirects = 306566#: Use socket.setdefaulttimeout() as fallback?67settings.timeout_fallback = True
modified:requests/exceptions.py+3 added
19 unmodified lines
20 """A valid URL is required to make a request."""2122class InvalidMethod(RequestException):23 """An inappropriate method was attempted."""2425class TooManyRedirects(RequestException):26 """Too many redirects."""
modified:requests/models.py+32 added-10 removed
19 unmodified lines
20from .structures import CaseInsensitiveDict21from .packages.poster.encode import multipart_encode22from .packages.poster.streaminghttp import register_openers, get_handlers23from .utils import dict_from_cookiejar24from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod24from .exceptions import RequestException, AuthenticationError, Timeout, URLRequired, InvalidMethod, TooManyRedirects25from .status_codes import codes262727REDIRECT_STATI = (301, 302, 303, 307)28REDIRECT_STATI = (codes.moved, codes.found, codes.other, codes.temporary_moved)29303132class Request(object):33 """The :class:`Request <models.Request>` object. It carries out all functionality of34 Requests. Recommended interface is with the Requests functions.35 """
139 unmodified lines
175176 try:177 response.headers = CaseInsensitiveDict(getattr(resp.info(), 'dict', None))178 response.read = resp.read179 response._resp = resp177 response.close = resp.close180 response._close = resp.close181182 if self.cookiejar:183184 response.cookies = dict_from_cookiejar(self.cookiejar)
18 unmodified lines
203204 while (205 ('location' in r.headers) and206 ((self.method in ('GET', 'HEAD')) or204 (r.status_code is 303) or207 (r.status_code is codes.see_other) or208 (self.allow_redirects))209 ):210211 r.close()212213 if not len(history) < settings.max_redirects:214 raise TooManyRedirects()215216 history.append(r)217218 url = r.headers['location']219220 # Handle redirection without scheme (see: RFC 1808 Section 4)221 if url.startswith('//'):222 parsed_rurl = urlparse(r.url)223 url = '%s:%s' % (parsed_rurl.scheme, url)224225 # Facilitate non-RFC2616-compliant 'location' headers226 # (e.g. '/path/to/resource' instead of 'http://domain.tld/path/to/resource')214 url = urljoin(r.url, url)227 if not urlparse(url).netloc:228 url = urljoin(r.url, urllib.quote(urllib.unquote(url)))229230 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4217 if r.status_code is 303:231 if r.status_code is codes.see_other:232 method = 'GET'233 else:234 method = self.method235
36 unmodified lines
272273 def _build_url(self):274 """Build the actual URL to use."""275262 # Support for unicode domain names.263 parsed_url = list(urlparse(self.url))264 parsed_url[1] = parsed_url[1].encode('idna')265 self.url = urlunparse(parsed_url)276 # Support for unicode domain names and paths.277 scheme, netloc, path, params, query, fragment = urlparse(self.url)278 netloc = netloc.encode('idna')279 if isinstance(path, unicode):280 path = path.encode('utf-8')281 path = urllib.quote(urllib.unquote(path))282 self.url = str(urlunparse([ scheme, netloc, path, params, query, fragment ]))283284 if self._enc_params:285 if urlparse(self.url).query:286 return '%s&%s' % (self.url, self._enc_params)
154 unmodified lines
441 if self.error:442 raise self.error443444445 def close(self):446 if self._resp.fp is not None and hasattr(self._resp.fp, '_sock'):447 self._resp.fp._sock.recv = None448 self._close()449450class AuthManager(object):451 """Requests Authentication Manager."""452453 def __new__(cls):
170 unmodified lines
modified:requests/status_codes.py+1 added-1 removed
22 unmodified lines
23 # Redirection.24 300: ('multiple_choices',),25 301: ('moved_permanently', 'moved', '\\o-'),26 302: ('found',),27 302: ('see_other', 'other'),27 303: ('see_other', 'other'),28 304: ('not_modified',),29 305: ('use_proxy',),30 306: ('switch_proxy',),31 307: ('temporary_redirect', 'temporary_moved', 'temporary'),
52 unmodified lines