Issue #10980: encode headers with latin1 instead of ASCII in the HTTP server.

This makes the implementation of PEP 3333 compliant servers on top of
BaseHTTPServer possible.
This commit is contained in:
Armin Ronacher 2011-01-22 13:13:05 +00:00
parent 137e0f0a22
commit 8d96d77f9a
3 changed files with 16 additions and 2 deletions

View file

@ -97,6 +97,11 @@ class BaseHTTPServerTestCase(BaseTestCase):
self.send_header('Connection', 'close')
self.end_headers()
def do_LATINONEHEADER(self):
self.send_response(999)
self.send_header('X-Special', 'Dängerous Mind')
self.end_headers()
def setUp(self):
BaseTestCase.setUp(self)
self.con = http.client.HTTPConnection('localhost', self.PORT)
@ -194,6 +199,11 @@ class BaseHTTPServerTestCase(BaseTestCase):
res = self.con.getresponse()
self.assertEqual(res.status, 999)
def test_latin1_header(self):
self.con.request('LATINONEHEADER', '/')
res = self.con.getresponse()
self.assertEqual(res.getheader('X-Special'), 'Dängerous Mind')
class SimpleHTTPServerTestCase(BaseTestCase):
class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler):