Mercurial > hg
view tests/test-eol-update @ 12570:a72c5ff1260c stable
Correct Content-Type header values for archive downloads.
The content type for both .tar.gz and .tar.bz2 downloads was
application/x-tar, which is correct for .tar files when no
Content-Encoding is present, but is not correct for .tar.gz and .tar.bz2
files unless Content-Encoding is set to gzip or x-bzip2, respectively.
However, setting Content-Encoding causes browsers to undo that encoding
during download, when a .gz or .bz2 file is usually the desired
artifact. Omitting the Content-Encoding header is preferred to avoid
having browsers uncompress non-render-able files.
Additionally, the Content-Disposition line indicates a final desired
filename with .tar.gz or .tar.bz2 extension which makes providing a
Content-Encoding header inappropriate.
With the current configuration browsers (Chrome and Firefox thus far)
are registering the application/x-tar Content-Type and not .tar
extension and appending that extension, yielding filename.tar.gz.tar as
a final on-disk artifact. This was originally reported here:
http://stackoverflow.com/questions/3753659
I've changed the .tar.gz and .tar.bz2 Content-Type values to
application/x-gzip and application/x-bzip2, respectively. Which yields
correctly named download artifacts on Firefox, Chrome, and IE.
author | Ry4an Brase <ry4an-hg@ry4an.org> |
---|---|
date | Mon, 20 Sep 2010 14:56:08 -0500 |
parents | 0bb67503ad4b |
children |
line wrap: on
line source
#!/bin/sh cat > $HGRCPATH <<EOF [diff] git = 1 EOF seteol () { if [ $1 = "LF" ]; then EOL='\n' else EOL='\r\n' fi } makerepo () { echo echo "# ==== setup repository ====" echo '% hg init' hg init repo cd repo cat > .hgeol <<EOF [patterns] **.txt = LF EOF printf "first\nsecond\nthird\n" > a.txt hg commit --addremove -m 'LF commit' cat > .hgeol <<EOF [patterns] **.txt = CRLF EOF printf "first\r\nsecond\r\nthird\r\n" > a.txt hg commit -m 'CRLF commit' cd .. } dotest () { seteol $1 echo echo "% hg clone repo repo-$1" hg clone --noupdate repo repo-$1 cd repo-$1 cat > .hg/hgrc <<EOF [extensions] eol = EOF hg update echo '% printrepr.py a.txt (before)' python $TESTDIR/printrepr.py < a.txt printf "first${EOL}third${EOL}" > a.txt echo '% printrepr.py a.txt (after)' python $TESTDIR/printrepr.py < a.txt echo '% hg diff' hg diff | python $TESTDIR/printrepr.py echo '% hg update 0' hg update 0 echo '% printrepr.py a.txt' python $TESTDIR/printrepr.py < a.txt echo '% hg diff' hg diff | python $TESTDIR/printrepr.py cd .. rm -r repo-$1 } makerepo dotest LF dotest CRLF rm -r repo