mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Remove req argument from Session.resolve_redirects
This commit is contained in:
+4
-2
@@ -8,9 +8,11 @@
|
||||
to most people and breaks most of the assumptions that people have about
|
||||
Response objects. This resolves issue `#2002`_
|
||||
|
||||
- Skip over empty chunks in iterators. Empty chunks could prematurely signal
|
||||
the end of a request body's transmission, skipping them allows all of the
|
||||
- Skip over empty chunks in iterators. Empty chunks could prematurely signal
|
||||
the end of a request body's transmission, skipping them allows all of the
|
||||
data through. See `#2631`_ for more details.
|
||||
|
||||
- Remove the ``req`` argument from ``Session.resolve_redirects`` method.
|
||||
|
||||
.. _#2002: https://github.com/kennethreitz/requests/issues/2002
|
||||
.. _#2631: https://github.com/kennethreitz/requests/issues/2631
|
||||
|
||||
@@ -88,12 +88,13 @@ def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
|
||||
|
||||
|
||||
class SessionRedirectMixin(object):
|
||||
def resolve_redirects(self, resp, req, stream=False, timeout=None,
|
||||
def resolve_redirects(self, resp, stream=False, timeout=None,
|
||||
verify=True, cert=None, proxies=None, **adapter_kwargs):
|
||||
"""Receives a Response. Returns a generator of Responses."""
|
||||
|
||||
i = 0
|
||||
hist = [] # keep track of history
|
||||
req = resp.request
|
||||
|
||||
while resp.is_redirect:
|
||||
prepared_request = req.copy()
|
||||
@@ -591,7 +592,7 @@ class Session(SessionRedirectMixin):
|
||||
extract_cookies_to_jar(self.cookies, request, r.raw)
|
||||
|
||||
# Redirect resolving generator.
|
||||
gen = self.resolve_redirects(r, request, **kwargs)
|
||||
gen = self.resolve_redirects(r, **kwargs)
|
||||
|
||||
# Resolve redirects if allowed.
|
||||
history = [resp for resp in gen] if allow_redirects else []
|
||||
|
||||
+2
-2
@@ -1072,7 +1072,7 @@ class TestRequests(object):
|
||||
s = requests.Session()
|
||||
r1 = s.get(httpbin('redirect/2'), allow_redirects=False, stream=True)
|
||||
assert r1.is_redirect
|
||||
rg = s.resolve_redirects(r1, r1.request, stream=True)
|
||||
rg = s.resolve_redirects(r1, stream=True)
|
||||
|
||||
# read only the first eight bytes of the response body,
|
||||
# then follow the redirect
|
||||
@@ -1661,7 +1661,7 @@ class TestRedirects:
|
||||
r0 = session.send(prep)
|
||||
assert r0.request.method == 'POST'
|
||||
assert session.calls[-1] == SendCall((r0.request,), {})
|
||||
redirect_generator = session.resolve_redirects(r0, prep)
|
||||
redirect_generator = session.resolve_redirects(r0)
|
||||
for response in redirect_generator:
|
||||
assert response.request.method == 'GET'
|
||||
send_call = SendCall((response.request,),
|
||||
|
||||
Reference in New Issue
Block a user