diff options
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/ui-shared.c b/ui-shared.c index fea2c40..66d5b82 100644 --- a/ui-shared.c +++ b/ui-shared.c | |||
@@ -34,6 +34,17 @@ void cgit_print_error(char *msg) | |||
34 | html("</div>\n"); | 34 | html("</div>\n"); |
35 | } | 35 | } |
36 | 36 | ||
37 | char *cgit_httpscheme() | ||
38 | { | ||
39 | char *https; | ||
40 | |||
41 | https = getenv("HTTPS"); | ||
42 | if (https != NULL && strcmp(https, "on") == 0) | ||
43 | return "https://"; | ||
44 | else | ||
45 | return "http://"; | ||
46 | } | ||
47 | |||
37 | char *cgit_hosturl() | 48 | char *cgit_hosturl() |
38 | { | 49 | { |
39 | char *host, *port; | 50 | char *host, *port; |
@@ -456,6 +467,10 @@ void cgit_print_age(time_t t, time_t max_relative, char *format) | |||
456 | 467 | ||
457 | void cgit_print_http_headers(struct cgit_context *ctx) | 468 | void cgit_print_http_headers(struct cgit_context *ctx) |
458 | { | 469 | { |
470 | const char *method = getenv("REQUEST_METHOD"); | ||
471 | |||
472 | if (ctx->page.status) | ||
473 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | ||
459 | if (ctx->page.mimetype && ctx->page.charset) | 474 | if (ctx->page.mimetype && ctx->page.charset) |
460 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 475 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
461 | ctx->page.charset); | 476 | ctx->page.charset); |
@@ -468,7 +483,11 @@ void cgit_print_http_headers(struct cgit_context *ctx) | |||
468 | ctx->page.filename); | 483 | ctx->page.filename); |
469 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 484 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
470 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 485 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
486 | if (ctx->page.etag) | ||
487 | htmlf("ETag: \"%s\"\n", ctx->page.etag); | ||
471 | html("\n"); | 488 | html("\n"); |
489 | if (method && !strcmp(method, "HEAD")) | ||
490 | exit(0); | ||
472 | } | 491 | } |
473 | 492 | ||
474 | void cgit_print_docstart(struct cgit_context *ctx) | 493 | void cgit_print_docstart(struct cgit_context *ctx) |
@@ -492,7 +511,8 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
492 | html("'/>\n"); | 511 | html("'/>\n"); |
493 | } | 512 | } |
494 | if (host && ctx->repo) { | 513 | if (host && ctx->repo) { |
495 | html("<link rel='alternate' title='Atom feed' href='http://"); | 514 | html("<link rel='alternate' title='Atom feed' href='"); |
515 | html(cgit_httpscheme()); | ||
496 | html_attr(cgit_hosturl()); | 516 | html_attr(cgit_hosturl()); |
497 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 517 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |
498 | fmt("h=%s", ctx->qry.head))); | 518 | fmt("h=%s", ctx->qry.head))); |