"""Receives a Response. Returns a generator of Responses."""
i = 0
- prepared_request = PreparedRequest()
- prepared_request.body = req.body
- prepared_request.headers = req.headers.copy()
- prepared_request.hooks = req.hooks
- prepared_request.method = req.method
- prepared_request.url = req.url
# ((resp.status_code is codes.see_other))
while (('location' in resp.headers and resp.status_code in REDIRECT_STATI)):
+ prepared_request = PreparedRequest()
+ prepared_request.body = req.body
+ prepared_request.headers = req.headers.copy()
+ prepared_request.hooks = req.hooks
resp.content # Consume socket so it can be released
resp.close()
url = resp.headers['location']
- method = prepared_request.method
+ method = req.method
# Handle redirection without scheme (see: RFC 1808 Section 4)
if url.startswith('//'):
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.4
if (resp.status_code == codes.see_other and
- prepared_request.method != 'HEAD'):
+ method != 'HEAD'):
method = 'GET'
# Do what the browsers do, despite standards...
if (resp.status_code in (codes.moved, codes.found) and
- prepared_request.method not in ('GET', 'HEAD')):
+ method not in ('GET', 'HEAD')):
method = 'GET'
prepared_request.method = method