diff -rud -u cpython/Lib.old/test/test_wsgiref.py cpython/Lib/test/test_wsgiref.py --- cpython/Lib.old/test/test_wsgiref.py 2014-10-17 01:53:14.000000000 +0200 +++ cpython/Lib/test/test_wsgiref.py 2014-12-10 13:38:04.000000000 +0100 @@ -46,6 +46,14 @@ ]) return ["Hello, world!"] +def hello_ml_app(environ,start_response): + start_response("200 OK", [ + ('Content-Type','text/plain'), + ('X-Multiline','first\r\n second\r\n third'), + ('Date','Mon, 05 Jun 2006 18:49:54 GMT') + ]) + return ["Hello, world!"] + def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"): server = make_server("", 80, app, MockServer, MockHandler) inp, out, err, olderr = StringIO(data), StringIO(), StringIO(), sys.stderr @@ -98,11 +106,13 @@ class IntegrationTests(TestCase): - def check_hello(self, out, has_length=True): + def check_hello(self, out, has_length=True, multiline=False): + multiline = "X-Multiline: first\r\n second\r\n third\r\n" if multiline else '' self.assertEqual(out, "HTTP/1.0 200 OK\r\n" "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n" "Content-Type: text/plain\r\n" + +multiline+ "Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" + (has_length and "Content-Length: 13\r\n" or "") + "\r\n" @@ -113,6 +123,10 @@ out, err = run_amock() self.check_hello(out) + def test_ml_hello(self): + out, err = run_amock(app=hello_ml_app) + self.check_hello(out, multiline=True) + def test_request_length(self): out, err = run_amock(data="GET " + ("x" * 65537) + " HTTP/1.0\n\n") self.assertEqual(out.splitlines()[0], @@ -123,6 +137,12 @@ # the middleware doesn't support len(), so content-length isn't there self.check_hello(out, has_length=False) + def test_validate_hello_ml(self): + out, err = run_amock(validator(hello_ml_app)) + self.assertTrue(out.endswith( + "A server error occurred. Please contact the administrator." + )) + def test_simple_validation_error(self): def bad_app(environ,start_response): start_response("200 OK", ('Content-Type','text/plain')) diff -rud -u cpython/Lib.old/wsgiref/simple_server.py cpython/Lib/wsgiref/simple_server.py --- cpython/Lib.old/wsgiref/simple_server.py 2014-10-17 01:53:18.000000000 +0200 +++ cpython/Lib/wsgiref/simple_server.py 2014-12-10 13:37:56.000000000 +0100 @@ -96,8 +96,7 @@ if length: env['CONTENT_LENGTH'] = length - for h in self.headers.headers: - k,v = h.split(':',1) + for k,v in self.headers.dict.items(): k=k.replace('-','_').upper(); v=v.strip() if k in env: continue # skip content length, type,etc.