diff options
-rw-r--r-- | wsgitools/scgi.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/wsgitools/scgi.py b/wsgitools/scgi.py index c12a296..51349a0 100644 --- a/wsgitools/scgi.py +++ b/wsgitools/scgi.py @@ -54,8 +54,9 @@ class SCGIConnection(asyncore.dispatcher): def _wsgi_write(self, data): assert self.state >= SCGIConnection.REQ - self._try_send_headers() - self.outbuff += data + if data: + self._try_send_headers() + self.outbuff += data def readable(self): """asyncore interface""" @@ -144,9 +145,9 @@ class SCGIConnection(asyncore.dispatcher): assert self.state >= SCGIConnection.REQ if len(self.outbuff) < self.BLOCK_SIZE: for data in self.wsgihandler: - self._try_send_headers() self.outbuff += data if len(self.outbuff) >= self.BLOCK_SIZE: + self._try_send_headers() break if len(self.outbuff) == 0: if hasattr(self.wsgihandler, "close"): |