From: Florian Best Date: Fri, 28 Jan 2022 20:00:58 +0000 (+0100) Subject: test[curl_httpclient]: add test case for ISO8859-1 header values X-Git-Tag: v6.2.0b1~32^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58d105fd7cfeb2d7da5aa11842e982756114007c;p=thirdparty%2Ftornado.git test[curl_httpclient]: add test case for ISO8859-1 header values --- diff --git a/tornado/test/httpclient_test.py b/tornado/test/httpclient_test.py index 6b6aced05..af5e01897 100644 --- a/tornado/test/httpclient_test.py +++ b/tornado/test/httpclient_test.py @@ -151,6 +151,11 @@ class InvalidGzipHandler(RequestHandler): self.write(body) +class HeaderEncodingHandler(RequestHandler): + def get(self): + self.finish(self.request.headers["Foo"].encode("ISO8859-1")) + + # These tests end up getting run redundantly: once here with the default # HTTPClient implementation, and then again in each implementation's own # test suite. @@ -175,6 +180,7 @@ class HTTPClientCommonTestCase(AsyncHTTPTestCase): url("/patch", PatchHandler), url("/set_header", SetHeaderHandler), url("/invalid_gzip", InvalidGzipHandler), + url("/header-encoding", HeaderEncodingHandler), ], gzip=True, ) @@ -537,6 +543,16 @@ X-XSS-Protection: 1; finally: self.io_loop.remove_handler(sock.fileno()) + @gen_test + def test_header_encoding(self): + response = yield self.http_client.fetch( + self.get_url("/header-encoding"), + headers={ + "Foo": "b\xe4r", + }, + ) + self.assertEqual(response.body, u"b\xe4r".encode("ISO8859-1")) + def test_304_with_content_length(self): # According to the spec 304 responses SHOULD NOT include # Content-Length or other entity headers, but some servers do it