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()