X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/b5a3a2049648415e86d518a8bf2229b3e463b10f..97b3d252629a8a3b9d356c2532dec7611438e4b9:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index fea2c40..015c52b 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -34,6 +34,17 @@ void cgit_print_error(char *msg) html("\n"); } +char *cgit_httpscheme() +{ + char *https; + + https = getenv("HTTPS"); + if (https != NULL && strcmp(https, "on") == 0) + return "https://"; + else + return "http://"; +} + char *cgit_hosturl() { char *host, *port; @@ -456,6 +467,13 @@ 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->cfg.embedded) + return; + + 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); @@ -468,11 +486,18 @@ 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) { + if (ctx->cfg.embedded) + return; + char *host = cgit_hosturl(); html(cgit_doctype); html("\n"); @@ -492,7 +517,8 @@ void cgit_print_docstart(struct cgit_context *ctx) html("'/>\n"); } if (host && ctx->repo) { - html("\n"); html("\n"); html(""); + if (!ctx->cfg.noheader) + print_header(ctx); html("
\n"); if (ctx->repo) {