statichttprepo: don't send Range header when requesting entire file stable
authorAlexander Boyd <alex@opengroove.org>
Sat, 09 Jun 2012 19:13:24 -0600
branchstable
changeset 16882 a2d6e336e9cc
parent 16880 15159abc5ab6
child 16946 d9238286964e
statichttprepo: don't send Range header when requesting entire file When requesting files using statichttprepo.httprangereader, a request for the entire file is sent with a Range: bytes=0- header. This causes problems with web servers such as Cherokee that return an HTTP 416 when an empty file is requested in this way, which in turn cause some repository clone attempts to fail. This patch omits the Range header when the entire file is being requested, which fixes the problem.
mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py	Wed Jun 06 21:17:20 2012 -0500
+++ b/mercurial/statichttprepo.py	Sat Jun 09 19:13:24 2012 -0600
@@ -26,7 +26,8 @@
         end = ''
         if bytes:
             end = self.pos + bytes - 1
-        req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
+        if self.pos or end:
+            req.add_header('Range', 'bytes=%d-%s' % (self.pos, end))
 
         try:
             f = self.opener.open(req)