We shouldn't be sending the data on redirect.
authorIan Cordasco <graffatcolmingov@gmail.com>
Fri, 8 Feb 2013 03:42:58 +0000 (22:42 -0500)
committerIan Cordasco <graffatcolmingov@gmail.com>
Sun, 10 Feb 2013 22:11:16 +0000 (17:11 -0500)
As such, we should remove the body from the old request as well as the
Content-Length header.

requests/sessions.py

index 8c1152c..7ee6221 100644 (file)
@@ -121,10 +121,13 @@ class SessionRedirectMixin(object):
 
             # Remove the cookie headers that were sent.
             headers = prepared_request.headers
-            try:
-                del headers['Cookie']
-            except KeyError:
-                pass
+            for h in ('Cookie', 'Content-Length'):
+                try:
+                    del headers[h]
+                except KeyError:
+                    pass
+
+            prepared_request.body = None
 
             resp = self.send(
                 prepared_request,