mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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.
This commit is contained in:
parent
8d96d77f9a
commit
59531287fd
3 changed files with 14 additions and 3 deletions
|
@ -100,7 +100,10 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
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 @@ class BaseHTTPServerTestCase(BaseTestCase):
|
|||
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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue