kennethreitz/requests — pull request #1930 by zackw (2014-02-26 00:34:55+00:00)
Title: Candidate "improve manual redirect-walking" core API change.

Sorry for dropping off the face of the earth for a while, folks. After reading the reaction to my previous pull request, I realized that the bugfixes I want to get in will be easier, cleaner, and make more sense in context if I make the big API change _first_. So this is the proposed big API change. It is not fully baked -- if nothing else, it needs tests -- but I'd like to get your opinion on the idea first.

* Session.send now offers a new mode, `iter_redirects=True`, in which
it returns an iterator over redirects _instead of_ the first response.
In this mode, the first request does not actually fire until you call
next() on the iterator the first time. Unlike the legacy
Session.resolve_redirects, the first response is included in the
generated sequence.

* Session.resolve_redirects is preserved and works as it always has, but
is now clearly documented as not the API you want. (The docstring for
Session.send itself probably needs some improvement as well.) Its
calling convention has been slightly polished: the request argument is
now optional (defaults to `resp.redirect`), it will accept arbitrary
kwargs to be passed to the adapter, and it defaults the same set of kwargs
from session settings as `send` itself does.

* The `allow_redirects=False` mode of `Session.send` also still works just
as it always has. If both allow_redirects=False and iter_redirects=True
are specified, allow_redirects=False wins.

* SessionRedirectMixin has been replaced by a RedirectIterator class
which is not a parent of Session.

* Response.history is now always a list.