From 1637616a8c7dc16beb6630ccab24799e2974ccbd Mon Sep 17 00:00:00 2001
From: Helmut Grohne <helmut@subdivi.de>
Date: Wed, 18 Apr 2007 10:36:25 +0200
Subject: fixed grave data sending bug in wsgitools.scgi

---
 wsgitools/scgi/asynchronous.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'wsgitools')

diff --git a/wsgitools/scgi/asynchronous.py b/wsgitools/scgi/asynchronous.py
index 51349a0..9510b4d 100644
--- a/wsgitools/scgi/asynchronous.py
+++ b/wsgitools/scgi/asynchronous.py
@@ -145,10 +145,11 @@ class SCGIConnection(asyncore.dispatcher):
         assert self.state >= SCGIConnection.REQ
         if len(self.outbuff) < self.BLOCK_SIZE:
             for data in self.wsgihandler:
-                self.outbuff += data
-                if len(self.outbuff) >= self.BLOCK_SIZE:
+                if data:
                     self._try_send_headers()
-                    break
+                    self.outbuff += data
+                    if len(self.outbuff) >= self.BLOCK_SIZE:
+                        break
             if len(self.outbuff) == 0:
                 if hasattr(self.wsgihandler, "close"):
                     self.wsgihandler.close()
-- 
cgit v1.2.3