fix content length. Test iff size == 0 before we start the loop.

This commit is contained in:
benoitc 2010-06-09 09:12:27 +02:00
parent 0beb39412d
commit c52e30bcef

View File

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