924
924
self.assertEqual(read_content.wait(), 'ok')
925
925
self.assert_(blew_up[0])
927
def test_exceptions_close_connection(self):
928
def wsgi_app(environ, start_response):
929
raise RuntimeError("intentional error")
930
self.site.application = wsgi_app
931
sock = eventlet.connect(('localhost', self.port))
932
fd = sock.makefile('rw')
933
fd.write('GET / HTTP/1.1\r\nHost: localhost\r\n\r\n')
935
response_line, headers, body = read_http(sock)
936
self.assert_(response_line.startswith('HTTP/1.1 500 Internal Server Error'))
937
self.assertEqual(headers['connection'], 'close')
938
self.assert_('transfer-encoding' not in headers)
940
def test_unicode_raises_error(self):
941
def wsgi_app(environ, start_response):
942
start_response("200 OK", [])
944
yield u"non-encodable unicode: \u0230"
945
self.site.application = wsgi_app
946
sock = eventlet.connect(('localhost', self.port))
947
fd = sock.makefile('rw')
948
fd.write('GET / HTTP/1.1\r\nHost: localhost\r\nConnection: close\r\n\r\n')
950
response_line, headers, body = read_http(sock)
951
self.assert_(response_line.startswith('HTTP/1.1 500 Internal Server Error'))
952
self.assertEqual(headers['connection'], 'close')
953
self.assert_('unicode' in body)
927
955
def read_headers(sock):
928
956
fd = sock.makefile()