Facundo Batista added the comment:

Mark is ok, zero length responses are ok. But that has nothing to do
with self.length.

self.lenght reaching zero means that everything that needed to be read
is already read. If the read() method is called without an argument, it
reads everything until it reaches self.lenght, and then it closes self.

So, when is called with an argument, is ok to close self if after
reading something self.length reaches zero (note that this actually
means that something was read, and self.length was lowered down...)

If self is closed also in this instance (see the patch), all tests pass
ok, and how you use HTTPConnection reading small pieces and not the
whole thing, is actually simplified...

----------
assignee:  -> facundobatista
keywords: +patch
versions: +Python 2.5 -Python 2.4

_____________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1580738>
_____________________________________
Index: Lib/httplib.py
===================================================================
--- Lib/httplib.py	(revisión: 58443)
+++ Lib/httplib.py	(copia de trabajo)
@@ -530,7 +530,8 @@
         s = self.fp.read(amt)
         if self.length is not None:
             self.length -= len(s)
-
+            if not self.length:
+                self.close()
         return s
 
     def _read_chunked(self, amt):
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to