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.
--- 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)