diff Lib/test/test_httpservers.py @ 67720:b3cadf5cf742

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.
author Armin Ronacher <armin.ronacher@active-4.com>
date Sat, 22 Jan 2011 13:44:22 +0000
parents 30c91342b6ae
children 3c9232a684ae
line wrap: on
line diff
--- a/Lib/test/test_httpservers.py	Sat Jan 22 13:13:05 2011 +0000
+++ b/Lib/test/test_httpservers.py	Sat Jan 22 13:44:22 2011 +0000
@@ -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):