summaryrefslogtreecommitdiffabout
path: root/ui-shared.c
Side-by-side diff
Diffstat (limited to 'ui-shared.c') (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 29036d0..10be3c0 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -464,12 +464,14 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
htmlf("<span class='age-years'>%.0f years</span>",
secs * 1.0 / TM_YEAR);
}
void cgit_print_http_headers(struct cgit_context *ctx)
{
+ const char *method = getenv("REQUEST_METHOD");
+
if (ctx->page.status)
htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg);
if (ctx->page.mimetype && ctx->page.charset)
htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype,
ctx->page.charset);
else if (ctx->page.mimetype)
@@ -478,13 +480,17 @@ void cgit_print_http_headers(struct cgit_context *ctx)
htmlf("Content-Length: %ld\n", ctx->page.size);
if (ctx->page.filename)
htmlf("Content-Disposition: inline; filename=\"%s\"\n",
ctx->page.filename);
htmlf("Last-Modified: %s\n", http_date(ctx->page.modified));
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);
}
void cgit_print_docstart(struct cgit_context *ctx)
{
char *host = cgit_hosturl();
html(cgit_doctype);