To match the behaviour of HTTP server, the HTTP client library now also encodes
headers with iso-8859-1 (latin1) encoding. It was already doing that for
incoming headers which makes this behaviour now consistent in both incoming and
outgoing direction.
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 2cc94a9..95b9c19 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -100,7 +100,10 @@
def do_LATINONEHEADER(self):
self.send_response(999)
self.send_header('X-Special', 'Dängerous Mind')
+ self.send_header('Connection', 'close')
self.end_headers()
+ body = self.headers['x-special-incoming'].encode('utf-8')
+ self.wfile.write(body)
def setUp(self):
BaseTestCase.setUp(self)
@@ -200,9 +203,12 @@
self.assertEqual(res.status, 999)
def test_latin1_header(self):
- self.con.request('LATINONEHEADER', '/')
+ self.con.request('LATINONEHEADER', '/', headers={
+ 'X-Special-Incoming': 'Ärger mit Unicode'
+ })
res = self.con.getresponse()
self.assertEqual(res.getheader('X-Special'), 'Dängerous Mind')
+ self.assertEqual(res.read(), 'Ärger mit Unicode'.encode('utf-8'))
class SimpleHTTPServerTestCase(BaseTestCase):