Skip to content

Commit

Permalink
Cleanup the redirect if blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa committed Nov 24, 2013
1 parent 470af31 commit 3369d87
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ def resolve_redirects(self, resp, req, stream=False, timeout=None,

# Do what the browsers do, despite standards...
# First, turn 302s into GETs.
if (resp.status_code == codes.found and
method not in ('GET', 'HEAD')):
if resp.status_code == codes.found and method != 'HEAD':
method = 'GET'

# Second, if a POST is responded to with a 301, turn it into a GET.
# This bizarre behaviour is explained in Issue 1704.
if (resp.status_code == codes.moved) and (method == 'POST'):
if resp.status_code == codes.moved and method == 'POST':
method = 'GET'

prepared_request.method = method
Expand Down

0 comments on commit 3369d87

Please sign in to comment.