summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2008-03-28 18:00:57 +0100
committerHelmut Grohne <helmut@subdivi.de>2008-03-28 18:00:57 +0100
commitcdf40b62af41540e4c57a2edfa62ea902d5d63d5 (patch)
tree50989a86dba587e27ce275fa4b08af0902a32190
parentcaf3a33e22af0d8060e32c2c2cb1a492ea146ef0 (diff)
downloadwsgitools-cdf40b62af41540e4c57a2edfa62ea902d5d63d5.tar.gz
implement size parameter for environ["wsgi.input"].readline on scgi.forkpool
-rw-r--r--wsgitools/scgi/forkpool.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/wsgitools/scgi/forkpool.py b/wsgitools/scgi/forkpool.py
index 3106d05..df92ec3 100644
--- a/wsgitools/scgi/forkpool.py
+++ b/wsgitools/scgi/forkpool.py
@@ -56,19 +56,29 @@ class SocketFileWrapper:
raise
return self.buff + data
- def readline(self):
+ def readline(self, size=None):
"""see pep333"""
while True:
try:
split = self.buff.index('\n') + 1
+ if size is not None and split > size:
+ split = size
ret, self.buff = self.buff[:split], self.buff[split:]
return ret
except ValueError:
- data = self._recv(4096)
+ if size is not None:
+ if len(self.buff) < size:
+ data = self._recv(size - len(self.buff))
+ else:
+ ret, self.buff = self.buff[:size], self.buff[size:]
+ return ret
+ else:
+ data = self._recv(4096)
if not data:
ret, self.buff = self.buff, ""
return ret
self.buff += data
+
def readlines(self):
"""see pep333"""
data = self.readline()