From c52e30bcef964dd87506f4aece60fd3767344038 Mon Sep 17 00:00:00 2001 From: benoitc Date: Wed, 9 Jun 2010 09:12:27 +0200 Subject: [PATCH] fix content length. Test iff size == 0 before we start the loop. --- gunicorn/http/body.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gunicorn/http/body.py b/gunicorn/http/body.py index 2b7873d9..0c82c25a 100644 --- a/gunicorn/http/body.py +++ b/gunicorn/http/body.py @@ -113,11 +113,13 @@ class LengthReader(object): def read(self, size): if not isinstance(size, (int, long)): raise TypeError("size must be an integral type") + + size = min(self.length, size) if size < 0: raise ValueError("Size must be positive.") if size == 0: return "" - size = min(self.length, size) + buf = StringIO() data = self.unreader.read()