]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
Merge branch 'plain-etag'
[ps-cgit] / ui-shared.c
index 29036d0a92ba45643e7db53af2671113fcbff7be..10be3c057dab494ad9782220374d0df258247cf0 100644 (file)
@@ -467,6 +467,8 @@ void cgit_print_age(time_t t, time_t max_relative, char *format)
 
 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)
@@ -481,7 +483,11 @@ void cgit_print_http_headers(struct cgit_context *ctx)
                      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)