Skip to content

Commit

Permalink
psf#3490 removing Content-Type and Transfer-Encoding headers on redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
nateprewitt committed Aug 10, 2016
1 parent e4b7040 commit aaa1294
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions requests/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,13 @@ def resolve_redirects(self, resp, req, stream=False, timeout=None,

self.rebuild_method(prepared_request, resp)

# https://github.com/kennethreitz/requests/issues/1084
# See https://github.com/kennethreitz/requests/issues/1084
# and https://github.com/kennethreitz/requests/issues/3490
if resp.status_code not in (codes.temporary_redirect, codes.permanent_redirect):
if 'Content-Length' in prepared_request.headers:
del prepared_request.headers['Content-Length']
purged_headers = ('Content-Length', 'Content-Type', 'Transfer-Encoding')
for header in purged_headers:
if header in prepared_request.headers:
del prepared_request.headers[header]

prepared_request.body = None

Expand Down

0 comments on commit aaa1294

Please sign in to comment.