Upgrading wsgi to also ignore tpooled AlreadyHandled results (because isinstance delibarately doesn't work on Proxy objects).
This commit is contained in:
@@ -333,7 +333,8 @@ class HttpProtocol(BaseHTTPServer.BaseHTTPRequestHandler):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
result = self.application(self.environ, start_response)
|
result = self.application(self.environ, start_response)
|
||||||
if isinstance(result, _AlreadyHandled):
|
if (isinstance(result, _AlreadyHandled)
|
||||||
|
or isinstance(getattr(result, '_obj', None), _AlreadyHandled)):
|
||||||
self.close_connection = 1
|
self.close_connection = 1
|
||||||
return
|
return
|
||||||
if not headers_sent and hasattr(result, '__len__') and \
|
if not headers_sent and hasattr(result, '__len__') and \
|
||||||
|
@@ -93,13 +93,13 @@ class IterableApp(object):
|
|||||||
return self.return_val
|
return self.return_val
|
||||||
|
|
||||||
class IterableSite(Site):
|
class IterableSite(Site):
|
||||||
|
|
||||||
def __call__(self, env, start_response):
|
def __call__(self, env, start_response):
|
||||||
iter = self.application(env, start_response)
|
it = self.application(env, start_response)
|
||||||
for i in iter:
|
for i in it:
|
||||||
yield i
|
yield i
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CONTENT_LENGTH = 'content-length'
|
CONTENT_LENGTH = 'content-length'
|
||||||
|
|
||||||
|
|
||||||
@@ -899,12 +899,14 @@ def read_headers(sock):
|
|||||||
return response_line, headers
|
return response_line, headers
|
||||||
|
|
||||||
class IterableAlreadyHandledTest(_TestBase):
|
class IterableAlreadyHandledTest(_TestBase):
|
||||||
|
|
||||||
def set_site(self):
|
def set_site(self):
|
||||||
self.site = IterableSite()
|
self.site = IterableSite()
|
||||||
|
|
||||||
|
def get_app(self):
|
||||||
|
return IterableApp(True)
|
||||||
|
|
||||||
def test_iterable_app_keeps_socket_open_unless_connection_close_sent(self):
|
def test_iterable_app_keeps_socket_open_unless_connection_close_sent(self):
|
||||||
self.site.application = IterableApp(True)
|
self.site.application = self.get_app()
|
||||||
sock = eventlet.connect(
|
sock = eventlet.connect(
|
||||||
('localhost', self.port))
|
('localhost', self.port))
|
||||||
|
|
||||||
@@ -922,6 +924,13 @@ class IterableAlreadyHandledTest(_TestBase):
|
|||||||
self.assertEqual(headers.get('transfer-encoding'), 'chunked')
|
self.assertEqual(headers.get('transfer-encoding'), 'chunked')
|
||||||
self.assertEqual(body, '0\r\n\r\n') # Still coming back chunked
|
self.assertEqual(body, '0\r\n\r\n') # Still coming back chunked
|
||||||
|
|
||||||
|
class ProxiedIterableAlreadyHandledTest(IterableAlreadyHandledTest):
|
||||||
|
# same thing as the previous test but ensuring that it works with tpooled
|
||||||
|
# results as well as regular ones
|
||||||
|
def get_app(self):
|
||||||
|
from eventlet import tpool
|
||||||
|
return tpool.Proxy(super(ProxiedIterableAlreadyHandledTest, self).get_app())
|
||||||
|
|
||||||
class TestChunkedInput(_TestBase):
|
class TestChunkedInput(_TestBase):
|
||||||
dirt = ""
|
dirt = ""
|
||||||
validator = None
|
validator = None
|
||||||
|
Reference in New Issue
Block a user