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.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 5e03a7a..015c52b 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -36,2 +36,13 @@ void cgit_print_error(char *msg)
+char *cgit_httpscheme()
+{
+ char *https;
+
+ https = getenv("HTTPS");
+ if (https != NULL && strcmp(https, "on") == 0)
+ return "https://";
+ else
+ return "http://";
+}
+
char *cgit_hosturl()
@@ -458,2 +469,4 @@ void cgit_print_http_headers(struct cgit_context *ctx)
{
+ const char *method = getenv("REQUEST_METHOD");
+
if (ctx->cfg.embedded)
@@ -461,2 +474,4 @@ void cgit_print_http_headers(struct cgit_context *ctx)
+ if (ctx->page.status)
+ htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg);
if (ctx->page.mimetype && ctx->page.charset)
@@ -473,3 +488,7 @@ void cgit_print_http_headers(struct cgit_context *ctx)
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);
}
@@ -500,3 +519,4 @@ void cgit_print_docstart(struct cgit_context *ctx)
if (host && ctx->repo) {
- html("<link rel='alternate' title='Atom feed' href='http://");
+ html("<link rel='alternate' title='Atom feed' href='");
+ html(cgit_httpscheme());
html_attr(cgit_hosturl());
@@ -504,4 +524,6 @@ void cgit_print_docstart(struct cgit_context *ctx)
fmt("h=%s", ctx->qry.head)));
- html("' type='application/atom+xml'/>");
+ html("' type='application/atom+xml'/>\n");
}
+ if (ctx->cfg.head_include)
+ html_include(ctx->cfg.head_include);
html("</head>\n");