changeset 2161:12e11413ca19

Fix just introduced possible old-http bug My last patch changed httprangereader.read to read only the specified amount of data from the connection, to prevent it from returning more than what was asked. I just realized that this could lead to the connection not being closed. In practice, it looks like the connection is closed just fine, but it's probably safer to read everything and then return only what's necessary.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sun, 30 Apr 2006 18:50:53 +0200
parents 858df1f354c1
children dac432a521d8
files mercurial/httprangereader.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httprangereader.py	Sun Apr 30 18:46:49 2006 +0200
+++ b/mercurial/httprangereader.py	Sun Apr 30 18:50:53 2006 +0200
@@ -22,4 +22,7 @@
             end = self.pos + bytes - 1
         req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
         f = urllib2.urlopen(req)
-        return f.read(bytes)
+        data = f.read()
+        if bytes:
+            data = data[:bytes]
+        return data