diff options
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 26 |
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 | |||
@@ -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,9 +467,13 @@ 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 | |||
459 | if (ctx->cfg.embedded) | 472 | if (ctx->cfg.embedded) |
460 | return; | 473 | return; |
461 | 474 | ||
475 | if (ctx->page.status) | ||
476 | htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg); | ||
462 | if (ctx->page.mimetype && ctx->page.charset) | 477 | if (ctx->page.mimetype && ctx->page.charset) |
463 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, | 478 | htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype, |
464 | ctx->page.charset); | 479 | ctx->page.charset); |
@@ -471,7 +486,11 @@ void cgit_print_http_headers(struct cgit_context *ctx) | |||
471 | ctx->page.filename); | 486 | ctx->page.filename); |
472 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); | 487 | htmlf("Last-Modified: %s\n", http_date(ctx->page.modified)); |
473 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); | 488 | htmlf("Expires: %s\n", http_date(ctx->page.expires)); |
489 | if (ctx->page.etag) | ||
490 | htmlf("ETag: \"%s\"\n", ctx->page.etag); | ||
474 | html("\n"); | 491 | html("\n"); |
492 | if (method && !strcmp(method, "HEAD")) | ||
493 | exit(0); | ||
475 | } | 494 | } |
476 | 495 | ||
477 | void cgit_print_docstart(struct cgit_context *ctx) | 496 | void cgit_print_docstart(struct cgit_context *ctx) |
@@ -498,12 +517,15 @@ void cgit_print_docstart(struct cgit_context *ctx) | |||
498 | html("'/>\n"); | 517 | html("'/>\n"); |
499 | } | 518 | } |
500 | if (host && ctx->repo) { | 519 | if (host && ctx->repo) { |
501 | html("<link rel='alternate' title='Atom feed' href='http://"); | 520 | html("<link rel='alternate' title='Atom feed' href='"); |
521 | html(cgit_httpscheme()); | ||
502 | html_attr(cgit_hosturl()); | 522 | html_attr(cgit_hosturl()); |
503 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, | 523 | html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.path, |
504 | fmt("h=%s", ctx->qry.head))); | 524 | fmt("h=%s", ctx->qry.head))); |
505 | html("' type='application/atom+xml'/>"); | 525 | html("' type='application/atom+xml'/>\n"); |
506 | } | 526 | } |
527 | if (ctx->cfg.head_include) | ||
528 | html_include(ctx->cfg.head_include); | ||
507 | html("</head>\n"); | 529 | html("</head>\n"); |
508 | html("<body>\n"); | 530 | html("<body>\n"); |
509 | if (ctx->cfg.header) | 531 | if (ctx->cfg.header) |