From: Kenneth Reitz Date: Sat, 31 Mar 2012 03:28:07 +0000 (-0400) Subject: POST redirect => GET X-Git-Tag: v0.11.1~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b20d171c1c11ecee83b7e4a0beead1e54902d37b;p=services%2Fpython-requests.git POST redirect => GET #269 --- diff --git a/requests/models.py b/requests/models.py index 881b7c1..b90f1a3 100644 --- a/requests/models.py +++ b/requests/models.py @@ -216,6 +216,7 @@ class Request(object): self.cookies.update(r.cookies) if r.status_code in REDIRECT_STATI and not self.redirect: + while (('location' in r.headers) and ((r.status_code is codes.see_other) or (self.allow_redirects))): @@ -250,6 +251,15 @@ class Request(object): else: method = self.method + # Do what the browsers do if strict_mode is off... + if (not self.config.get('strict_mode')): + + if r.status_code in (codes.moved, codes.found) and self.method == 'POST': + method = 'GET' + + if (r.status_code == 303) and self.method != 'HEAD': + method = 'GET' + # Remove the cookie headers that were sent. headers = self.headers try: