Skip to content

Commit 45752bf

Browse files
committed
Clear Content-Encoding and Transfer-Encoding
Also better test names.
1 parent 6cd8e08 commit 45752bf

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

tornado/simple_httpclient.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ def _on_body(self, data):
361361
if self.code == 303:
362362
new_request.method = "GET"
363363
new_request.body = None
364-
for h in ["Content-Length", "Content-Type"]:
364+
for h in ["Content-Length", "Content-Type",
365+
"Content-Encoding", "Transfer-Encoding"]:
365366
try:
366367
del self.request.headers[h]
367368
except KeyError:

tornado/test/simple_httpclient_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ def get(self):
4444
self.set_header("Content-Length", self.get_argument("value"))
4545
self.write("ok")
4646

47-
class PRGPostHandler(RequestHandler):
47+
class SeeOther303PostHandler(RequestHandler):
4848
def post(self):
49-
self.set_header("Location", "/prg_get")
49+
self.set_header("Location", "/303_get")
5050
self.set_status(303)
5151

52-
class PRGGetHandler(RequestHandler):
52+
class SeeOther303GetHandler(RequestHandler):
5353
def get(self):
5454
self.write("ok")
5555

@@ -66,8 +66,8 @@ def get_app(self):
6666
url("/hang", HangHandler),
6767
url("/hello", HelloWorldHandler),
6868
url("/content_length", ContentLengthHandler),
69-
url("/prg_post", PRGPostHandler),
70-
url("/prg_get", PRGGetHandler),
69+
url("/303_post", SeeOther303PostHandler),
70+
url("/303_get", SeeOther303GetHandler),
7171
], gzip=True)
7272

7373
def test_singleton(self):
@@ -147,10 +147,10 @@ def test_max_redirects(self):
147147
self.assertTrue(response.headers["Location"].endswith("/countdown/1"))
148148

149149
def test_303_redirect(self):
150-
response = self.fetch("/prg_post", method="POST", body="")
150+
response = self.fetch("/303_post", method="POST", body="")
151151
self.assertEqual(200, response.code)
152-
self.assertTrue(response.request.url.endswith("/prg_post"))
153-
self.assertTrue(response.effective_url.endswith("/prg_get"))
152+
self.assertTrue(response.request.url.endswith("/303_post"))
153+
self.assertTrue(response.effective_url.endswith("/303_get"))
154154
#request is the original request, is a POST still
155155
self.assertEqual("POST", response.request.method)
156156

0 commit comments

Comments
 (0)