diff options
Diffstat (limited to 'wsgitools/scgi/forkpool.py')
-rw-r--r-- | wsgitools/scgi/forkpool.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py index aa316d1..cdd50f0 100644 --- a/wsgitools/scgi/forkpool.py +++ b/wsgitools/scgi/forkpool.py @@ -12,7 +12,7 @@ import sys import errno import signal -from wsgitools.scgi import _convert_environ +from wsgitools.scgi import _convert_environ, FileWrapper if sys.version_info[0] >= 3: def exc_info_for_raise(exc_info): @@ -444,13 +444,19 @@ class SCGIServer: result = self.wsgiapp(environ, start_response) assert hasattr(result, "__iter__") - assert response_head[0] is not None - result_iter = iter(result) - for data in result_iter: - assert isinstance(data, str) - dumbsend(data) - if response_head[0] != True: + if isinstance(result, FileWrapper) and result.can_transfer(): sendheaders() + sent = 1 + while sent > 0: + sent = result.transfer(con) + else: + assert response_head[0] is not None + result_iter = iter(result) + for data in result_iter: + assert isinstance(data, str) + dumbsend(data) + if response_head[0] != True: + sendheaders() if hasattr(result, "close"): result.close() sfw.close() |