From: Lars Hjemli Date: Sat, 25 Jul 2009 09:59:22 +0000 (+0200) Subject: Merge branch 'plain-etag' X-Git-Tag: v0.8.3~28 X-Git-Url: https://git.cameronkatri.com/cgit.git/commitdiff_plain/681fdc45473143de3f3c5f69fbc7b94f5d6b0b75 Merge branch 'plain-etag' Conflicts: ui-shared.c --- 681fdc45473143de3f3c5f69fbc7b94f5d6b0b75 diff --cc cgit.h index 00aca4c,2bfbe7b..07a277a --- a/cgit.h +++ b/cgit.h @@@ -180,9 -180,8 +180,10 @@@ struct cgit_page char *mimetype; char *charset; char *filename; + char *etag; char *title; + int status; + char *statusmsg; }; struct cgit_context { diff --cc ui-plain.c index 9a9ae7d,f73cd14..93a3a05 --- a/ui-plain.c +++ b/ui-plain.c @@@ -31,12 -31,10 +31,13 @@@ static void print_object(const unsigne html_status(404, "Not found", 0); return; } - ctx.page.mimetype = "text/plain"; + if (buffer_is_binary(buf, size)) + ctx.page.mimetype = "application/octet-stream"; + else + ctx.page.mimetype = "text/plain"; ctx.page.filename = fmt("%s", path); ctx.page.size = size; + ctx.page.etag = sha1_to_hex(sha1); cgit_print_http_headers(&ctx); html_raw(buf, size); match = 1; diff --cc ui-shared.c index 29036d0,0dafc83..10be3c0 --- a/ui-shared.c +++ b/ui-shared.c @@@ -467,8 -456,8 +467,10 @@@ void cgit_print_age(time_t t, time_t ma 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);