From 69982ed46c2ceee3837d8e26c0fd48c9ec32ca95 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 4 Sep 2019 15:10:55 +0100 Subject: [PATCH] Strip Transfer-Encoding when a switch-to-GET redirect is made --- httpx/middleware.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/httpx/middleware.py b/httpx/middleware.py index b14037d4..aa994dba 100644 --- a/httpx/middleware.py +++ b/httpx/middleware.py @@ -151,8 +151,10 @@ class RedirectMiddleware(BaseMiddleware): del headers["Host"] if method != request.method and method == "GET": - # Strip Content-Length headers when we've switch to a 'GET' request. + # If we've switch to a 'GET' request, then strip any headers which + # are only relevant to the request body. del headers["Content-Length"] + del headers["Transfer-Encoding"] return headers