summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2009-07-25 09:59:22 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2009-07-25 09:59:22 (UTC)
commit681fdc45473143de3f3c5f69fbc7b94f5d6b0b75 (patch) (side-by-side diff)
tree3bfca05875524bee0e5444fb791707bc3e593dbd
parent7e5c048505efe1902fb476cc2cb3160ff7df013d (diff)
parent3ff58ddd51bcbcbc9b7649bad1a39aa98af4b49f (diff)
downloadcgit-681fdc45473143de3f3c5f69fbc7b94f5d6b0b75.zip
cgit-681fdc45473143de3f3c5f69fbc7b94f5d6b0b75.tar.gz
cgit-681fdc45473143de3f3c5f69fbc7b94f5d6b0b75.tar.bz2
Merge branch 'plain-etag'
Conflicts: ui-shared.c
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c4
-rw-r--r--cgit.h1
-rw-r--r--ui-plain.c1
-rw-r--r--ui-shared.c6
4 files changed, 12 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index 19adadd..ae20257 100644
--- a/cgit.c
+++ b/cgit.c
@@ -208,2 +208,3 @@ static void prepare_context(struct cgit_context *ctx)
ctx->page.expires = ctx->page.modified;
+ ctx->page.etag = NULL;
}
@@ -433,2 +434,3 @@ int main(int argc, const char **argv)
const char *cgit_config_env = getenv("CGIT_CONFIG");
+ const char *method = getenv("REQUEST_METHOD");
const char *path;
@@ -479,2 +481,4 @@ int main(int argc, const char **argv)
ctx.page.expires += ttl*60;
+ if (method && !strcmp(method, "HEAD"))
+ ctx.cfg.nocache = 1;
if (ctx.cfg.nocache)
diff --git a/cgit.h b/cgit.h
index 00aca4c..07a277a 100644
--- a/cgit.h
+++ b/cgit.h
@@ -182,2 +182,3 @@ struct cgit_page {
char *filename;
+ char *etag;
char *title;
diff --git a/ui-plain.c b/ui-plain.c
index 9a9ae7d..93a3a05 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -39,2 +39,3 @@ static void print_object(const unsigned char *sha1, const char *path)
ctx.page.size = size;
+ ctx.page.etag = sha1_to_hex(sha1);
cgit_print_http_headers(&ctx);
diff --git a/ui-shared.c b/ui-shared.c
index 29036d0..10be3c0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -469,2 +469,4 @@ void cgit_print_http_headers(struct cgit_context *ctx)
{
+ const char *method = getenv("REQUEST_METHOD");
+
if (ctx->page.status)
@@ -483,3 +485,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
htmlf("Expires: %s\n", http_date(ctx->page.expires));
+ if (ctx->page.etag)
+ htmlf("ETag: \"%s\"\n", ctx->page.etag);
html("\n");
+ if (method && !strcmp(method, "HEAD"))
+ exit(0);
}