comparison mercurial/hgweb.py @ 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 27f2ec705332
comparison
equal deleted inserted replaced
1182:24d553b598e8 1185:2ae9c319e6fe
687 687
688 tf = tarfile.TarFile.open(mode='w|' + type, fileobj=req.out) 688 tf = tarfile.TarFile.open(mode='w|' + type, fileobj=req.out)
689 mff = self.repo.manifest.readflags(mnode) 689 mff = self.repo.manifest.readflags(mnode)
690 mtime = int(time.time()) 690 mtime = int(time.time())
691 691
692 req.httphdr('application/octet-stream', name[:-1] + '.tar.' + type) 692 if type == "gz":
693 encoding = "gzip"
694 else:
695 encoding = "x-bzip2"
696 req.header([('Content-type', 'application/x-tar'),
697 ('Content-disposition', 'attachment; filename=%s%s%s' %
698 (name[:-1], '.tar.', type)),
699 ('Content-encoding', encoding)])
693 for fname in files: 700 for fname in files:
694 rcont = self.repo.file(fname).read(mf[fname]) 701 rcont = self.repo.file(fname).read(mf[fname])
695 finfo = tarfile.TarInfo(name + fname) 702 finfo = tarfile.TarInfo(name + fname)
696 finfo.mtime = mtime 703 finfo.mtime = mtime
697 finfo.size = len(rcont) 704 finfo.size = len(rcont)