Test and fix for weird 'Unexpected EOF' error discovered through use. wsgi_test.py may not be the best place for this test but at least it's there.

This commit is contained in:
Ryan Williams
2009-06-02 15:06:12 -07:00
parent abda8d075b
commit e297081648
2 changed files with 22 additions and 1 deletions

View File

@@ -558,6 +558,13 @@ class GreenSSL(GreenSocket):
read = read
def sendall(self, data):
# overriding sendall because ssl sockets behave badly when asked to
# send empty strings; 'normal' sockets don't have a problem
if not data:
return
super(GreenSSL, self).sendall(data)
def write(self, data):
try:
return self.sendall(data)

View File

@@ -1,5 +1,5 @@
"""\
@file httpd_test.py
@file wsgi_test.py
@author Donovan Preston
Copyright (c) 2007, Linden Research, Inc.
@@ -281,6 +281,20 @@ class TestHttpd(tests.TestCase):
result = httpc.post("https://localhost:4201/foo", "abc")
self.assertEquals(result, 'abc')
def test_013_empty_return(self):
from eventlet import httpc
def wsgi_app(environ, start_response):
start_response("200 OK", [])
return [""]
certificate_file = os.path.join(os.path.dirname(__file__), 'test_server.crt')
private_key_file = os.path.join(os.path.dirname(__file__), 'test_server.key')
sock = api.ssl_listener(('', 4202), certificate_file, private_key_file)
api.spawn(wsgi.server, sock, wsgi_app)
res = httpc.get("https://localhost:4202/foo")
self.assertEquals(res, '')
if __name__ == '__main__':
tests.main()