[Python-checkins] python/dist/src/Lib httplib.py,1.93,1.94

jhylton at users.sourceforge.net jhylton at users.sourceforge.net
Sun Nov 7 17:13:12 CET 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25550/dist/src/Lib

Modified Files:
	httplib.py 
Log Message:
Fix for SF bug 988120 via patch 1061941.

If read() returned less than the number of bytes request, the full amount was subtracted from length instead of the actually read amount.

Index: httplib.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/httplib.py,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- httplib.py	14 Oct 2004 15:23:38 -0000	1.93
+++ httplib.py	7 Nov 2004 16:13:09 -0000	1.94
@@ -457,10 +457,11 @@
 
         if amt is None:
             # unbounded read
-            if self.will_close:
+            if self.length is None:
                 s = self.fp.read()
             else:
                 s = self._safe_read(self.length)
+                self.length = 0
             self.close()        # we read everything
             return s
 
@@ -468,12 +469,13 @@
             if amt > self.length:
                 # clip the read to the "end of response"
                 amt = self.length
-            self.length -= amt
 
         # we do not use _safe_read() here because this may be a .will_close
         # connection, and the user is reading more bytes than will be provided
         # (for example, reading in 1k chunks)
         s = self.fp.read(amt)
+        if self.length is not None:
+            self.length -= len(s)
 
         return s
 



More information about the Python-checkins mailing list