From e2ad0d0fe8f4bff1640417f67e7e321f030c1bed Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Thu, 7 Feb 2013 22:42:58 -0500 Subject: [PATCH] We shouldn't be sending the data on redirect. As such, we should remove the body from the old request as well as the Content-Length header. --- requests/sessions.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/requests/sessions.py b/requests/sessions.py index 8c1152c..7ee6221 100644 --- a/requests/sessions.py +++ b/requests/sessions.py @@ -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, -- 2.7.4