changeset 1185:2ae9c319e6fe

Output Content-encoding for tar.gz and tar.bz2 snapshots If the HTTP header 'Content-encoding' is missing for tar.gz snapshots, some gzip capable proxies can bork the tarball and serve unusable files to users. GZ tarballs are served using Content-encoding: gzip. BZ2 tarballs are served using Content-encoding: x-bzip2.
author Edouard Gomez <ed.gomez@free.fr>
date Thu, 01 Sep 2005 07:41:32 -0700
parents 24d553b598e8
children 508c7d1b3e1c
files mercurial/hgweb.py
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb.py	Wed Aug 31 21:07:36 2005 +0200
+++ b/mercurial/hgweb.py	Thu Sep 01 07:41:32 2005 -0700
@@ -689,7 +689,14 @@
             mff = self.repo.manifest.readflags(mnode)
             mtime = int(time.time())
 
-            req.httphdr('application/octet-stream', name[:-1] + '.tar.' + type)
+            if type == "gz":
+                encoding = "gzip"
+            else:
+                encoding = "x-bzip2"
+            req.header([('Content-type', 'application/x-tar'), 
+                    ('Content-disposition', 'attachment; filename=%s%s%s' %
+                        (name[:-1], '.tar.', type)),
+                    ('Content-encoding', encoding)])
             for fname in files:
                 rcont = self.repo.file(fname).read(mf[fname])
                 finfo = tarfile.TarInfo(name + fname)