tests/test-serve
author Ry4an Brase <ry4an-hg@ry4an.org>
Mon, 20 Sep 2010 14:56:08 -0500
branchstable
changeset 12570 a72c5ff1260c
parent 10633 3318431f2ab4
child 12076 49463314c24f
permissions -rwxr-xr-x
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.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4504
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
     1
#!/bin/sh
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
     2
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
     3
hgserve()
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
     4
{
10633
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
     5
    hg serve -a localhost -d --pid-file=hg.pid -E errors.log -v $@ \
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
     6
        | sed -e "s/:$HGPORT1\\([^0-9]\\)/:HGPORT1\1/g" \
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
     7
              -e "s/:$HGPORT2\\([^0-9]\\)/:HGPORT2\1/g" \
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
     8
              -e 's/http:\/\/[^/]*\//http:\/\/localhost\//'
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
     9
    cat hg.pid >> "$DAEMON_PIDS"
6461
eb69e7989145 tests: easier error diagnostics for test-serve
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6331
diff changeset
    10
    echo % errors
eb69e7989145 tests: easier error diagnostics for test-serve
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6331
diff changeset
    11
    cat errors.log
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    12
    sleep 1
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    13
    kill `cat hg.pid`
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    14
    sleep 1
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    15
}
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    16
4504
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    17
hg init test
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    18
cd test
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    19
4835
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4506
diff changeset
    20
echo '[web]' > .hg/hgrc
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4506
diff changeset
    21
echo 'accesslog = access.log' >> .hg/hgrc
10633
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
    22
echo "port = $HGPORT1" >> .hg/hgrc
4835
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4506
diff changeset
    23
4504
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    24
echo % Without -v
6461
eb69e7989145 tests: easier error diagnostics for test-serve
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6331
diff changeset
    25
hg serve -a localhost -p $HGPORT -d --pid-file=hg.pid -E errors.log
4506
9f952dd4413b test-serve: let run-tests.py kill the daemons
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4504
diff changeset
    26
cat hg.pid >> "$DAEMON_PIDS"
4835
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4506
diff changeset
    27
if [ -f access.log ]; then
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4506
diff changeset
    28
    echo 'access log created - .hg/hgrc respected'
9858477ed74c serve: respect settings from .hg/hgrc
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 4506
diff changeset
    29
fi
6461
eb69e7989145 tests: easier error diagnostics for test-serve
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6331
diff changeset
    30
echo % errors
eb69e7989145 tests: easier error diagnostics for test-serve
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 6331
diff changeset
    31
cat errors.log
4504
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    32
c68e6486f295 Add test reproducing a bug in "hg serve -v"
Joel Rosdahl <joel@rosdahl.net>
parents:
diff changeset
    33
echo % With -v
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    34
hgserve
5971
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    35
10633
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
    36
echo % With -v and -p HGPORT2
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
    37
hgserve -p "$HGPORT2"
3318431f2ab4 test-serve: Show if port config and option are correctly used
Thomas Arendsen Hein <thomas@intevation.de>
parents: 6461
diff changeset
    38
5971
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    39
echo % With --prefix foo
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    40
hgserve --prefix foo
5971
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    41
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    42
echo % With --prefix /foo
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    43
hgserve --prefix /foo
5971
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    44
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    45
echo % With --prefix foo/
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    46
hgserve --prefix foo/
5971
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    47
6d5ecf824a65 tests for hg serve prefix option
Michele Cella <michele.cella@gmail.com>
parents: 5384
diff changeset
    48
echo % With --prefix /foo/
6300
874ca958025b test-serve: replace copy/paste with shell function
Patrick Mezard <pmezard@gmail.com>
parents: 6262
diff changeset
    49
hgserve --prefix /foo/