From 179420b66aa54a676dbd5ce77dff28688d6a9d1d Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Mon, 16 Apr 2007 18:01:33 +0200 Subject: delay sending headers in scgi server when possible --- wsgitools/scgi.py | 7 ++++--- 1 file 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"): -- cgit v1.2.3