-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | ui-plain.c | 1 | ||||
-rw-r--r-- | ui-shared.c | 6 |
4 files changed, 12 insertions, 0 deletions
@@ -207,4 +207,5 @@ static void prepare_context(struct cgit_context *ctx) | |||
207 | ctx->page.modified = time(NULL); | 207 | ctx->page.modified = time(NULL); |
208 | ctx->page.expires = ctx->page.modified; | 208 | ctx->page.expires = ctx->page.modified; |
209 | ctx->page.etag = NULL; | ||
209 | } | 210 | } |
210 | 211 | ||
@@ -432,4 +433,5 @@ int main(int argc, const char **argv) | |||
432 | { | 433 | { |
433 | const char *cgit_config_env = getenv("CGIT_CONFIG"); | 434 | const char *cgit_config_env = getenv("CGIT_CONFIG"); |
435 | const char *method = getenv("REQUEST_METHOD"); | ||
434 | const char *path; | 436 | const char *path; |
435 | char *qry; | 437 | char *qry; |
@@ -478,4 +480,6 @@ int main(int argc, const char **argv) | |||
478 | ttl = calc_ttl(); | 480 | ttl = calc_ttl(); |
479 | ctx.page.expires += ttl*60; | 481 | ctx.page.expires += ttl*60; |
482 | if (method && !strcmp(method, "HEAD")) | ||
483 | ctx.cfg.nocache = 1; | ||
480 | if (ctx.cfg.nocache) | 484 | if (ctx.cfg.nocache) |
481 | ctx.cfg.cache_size = 0; | 485 | ctx.cfg.cache_size = 0; |
@@ -181,4 +181,5 @@ struct cgit_page { | |||
181 | char *charset; | 181 | char *charset; |
182 | char *filename; | 182 | char *filename; |
183 | char *etag; | ||
183 | char *title; | 184 | char *title; |
184 | int status; | 185 | int status; |
@@ -38,4 +38,5 @@ static void print_object(const unsigned char *sha1, const char *path) | |||
38 | ctx.page.filename = fmt("%s", path); | 38 | ctx.page.filename = fmt("%s", path); |
39 | ctx.page.size = size; | 39 | ctx.page.size = size; |
40 | ctx.page.etag = sha1_to_hex(sha1); | ||
40 | cgit_print_http_headers(&ctx); | 41 | cgit_print_http_headers(&ctx); |
41 | html_raw(buf, size); | 42 | html_raw(buf, size); |
diff --git a/ui-shared.c b/ui-shared.c index 29036d0..10be3c0 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -468,4 +468,6 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
468 | void cgit_print_http_headers(struct cgit_context *ctx) | 468 | void cgit_print_http_headers(struct cgit_context *ctx) |
469 | { | 469 | { |
470 | const char *method = getenv("REQUEST_METHOD"); | ||
471 | |||
470 | if (ctx->page.status) | 472 | if (ctx->page.status) |
471 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | 473 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); |
@@ -482,5 +484,9 @@ void cgit_print_http_headers(struct cgit_context *ctx) | |||
482 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 484 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
483 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 485 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
486 | if (ctx->page.etag) | ||
487 | htmlf("ETag: \"%s\"\n", ctx->page.etag); | ||
484 | html("\n"); | 488 | html("\n"); |
489 | if (method && !strcmp(method, "HEAD")) | ||
490 | exit(0); | ||
485 | } | 491 | } |
486 | 492 | ||