message = ''
if self.request_version != 'HTTP/0.9':
self.wfile.write(("%s %d %s\r\n" %
- (self.protocol_version, code, message)).encode('ASCII', 'strict'))
+ (self.protocol_version, code, message)).encode('latin1', 'strict'))
def send_header(self, keyword, value):
"""Send a MIME header."""
if not hasattr(self, '_headers_buffer'):
self._headers_buffer = []
self._headers_buffer.append(
- ("%s: %s\r\n" % (keyword, value)).encode('ASCII', 'strict'))
+ ("%s: %s\r\n" % (keyword, value)).encode('latin1', 'strict'))
if keyword.lower() == 'connection':
if value.lower() == 'close':
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)
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):
- Issue #10898: Allow compiling the posix module when the C library defines
a symbol named FSTAT.
+- Issue #10980: the HTTP server now encodes headers with iso-8859-1 (latin1)
+ encoding. This is the preferred encoding of PEP 3333 and the base encoding
+ of HTTP 1.1.
+
What's New in Python 3.2 Release Candidate 1
============================================