changeset 16882:a2d6e336e9cc stable

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.
author Alexander Boyd <alex@opengroove.org>
date Sat, 09 Jun 2012 19:13:24 -0600
parents 15159abc5ab6
children d9238286964e
files mercurial/statichttprepo.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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)