diff options
author | W. Trevor King <wking@drexel.edu> | 2012-03-26 15:14:19 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-03-26 12:56:06 -0700 |
commit | 84d62947b59e1c49f36b77e2469b39723c503a39 (patch) | |
tree | 36e39b1d04a730554153a2419b31e7b12116d6ca /t/t9501-gitweb-standalone-http-status.sh | |
parent | d037873021736010d1e9095fe9094f24d57b87c5 (diff) | |
download | git-wk/gitweb-snapshot-use-if-modified-since.tar.gz |
gitweb: add If-Modified-Since handling to git_snapshot().wk/gitweb-snapshot-use-if-modified-since
Because snapshots can be large, you can save some bandwidth by
supporting caching via If-Modified-Since. This patch adds support for
the i-m-s request to git_snapshot() if the requested hash is a commit.
Requests for snapshots of tree-ishes, which lack well defined
timestamps, are still handled as they were before.
Signed-off-by: W Trevor King <wking@drexel.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t9501-gitweb-standalone-http-status.sh')
-rwxr-xr-x | t/t9501-gitweb-standalone-http-status.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/t/t9501-gitweb-standalone-http-status.sh b/t/t9501-gitweb-standalone-http-status.sh index 537c966799..3b7a00671d 100755 --- a/t/t9501-gitweb-standalone-http-status.sh +++ b/t/t9501-gitweb-standalone-http-status.sh @@ -138,6 +138,39 @@ test_expect_success 'modification: feed if-modified-since (unmodified)' ' ' test_debug 'cat gitweb.headers' +test_expect_success 'modification: snapshot last-modified' ' + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + grep "Status: 200 OK" gitweb.output && + grep "Last-modified: Thu, 7 Apr 2005 22:14:13 +0000" gitweb.output +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: snapshot if-modified-since (modified)' ' + export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + unset HTTP_IF_MODIFIED_SINCE && + grep "Status: 200 OK" gitweb.output +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: snapshot if-modified-since (unmodified)' ' + export HTTP_IF_MODIFIED_SINCE="Thu, 7 Apr 2005 22:14:13 +0000" && + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + unset HTTP_IF_MODIFIED_SINCE && + grep "Status: 304 Not Modified" gitweb.output +' +test_debug 'cat gitweb.headers' + +test_expect_success 'modification: tree-ish snapshot' ' + ID=`git rev-parse --verify HEAD^{tree}` && + export HTTP_IF_MODIFIED_SINCE="Wed, 6 Apr 2005 22:14:13 +0000" && + gitweb_run "p=.git;a=snapshot;h=master;sf=tgz" && + unset HTTP_IF_MODIFIED_SINCE && + grep "Status: 200 OK" gitweb.output && + ! grep "Last-Modified" gitweb.output +' +test_debug 'cat gitweb.headers' + # ---------------------------------------------------------------------- # load checking |