]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-shared.c
use Host: header to generate cgit_hosturl
[ps-cgit] / ui-shared.c
index 37c60b25d2c8ed1e4cecba4d2bd8873884a1baef..c23bc7540b9862bb200afba1bd46b7af7a119896 100644 (file)
@@ -38,14 +38,19 @@ char *cgit_hosturl()
 {
        char *host, *port;
 
-       host = getenv("SERVER_NAME");
-       if (!host)
-               return NULL;
-       port = getenv("SERVER_PORT");
-       if (port && atoi(port) != 80)
-               host = xstrdup(fmt("%s:%d", host, atoi(port)));
-       else
+       host = getenv("HTTP_HOST");
+       if (host) {
                host = xstrdup(host);
+       } else {
+               host = getenv("SERVER_NAME");
+               if (!host)
+                       return NULL;
+               port = getenv("SERVER_PORT");
+               if (port && atoi(port) != 80)
+                       host = xstrdup(fmt("%s:%d", host, atoi(port)));
+               else
+                       host = xstrdup(host);
+       }
        return host;
 }
 
@@ -258,6 +263,12 @@ void cgit_tree_link(char *name, char *title, char *class, char *head,
        reporevlink("tree", name, title, class, head, rev, path);
 }
 
+void cgit_plain_link(char *name, char *title, char *class, char *head,
+                    char *rev, char *path)
+{
+       reporevlink("plain", name, title, class, head, rev, path);
+}
+
 void cgit_log_link(char *name, char *title, char *class, char *head,
                   char *rev, char *path, int ofs, char *grep, char *pattern)
 {
@@ -433,6 +444,8 @@ void cgit_print_http_headers(struct cgit_context *ctx)
                      ctx->page.charset);
        else if (ctx->page.mimetype)
                htmlf("Content-Type: %s\n", ctx->page.mimetype);
+       if (ctx->page.size)
+               htmlf("Content-Length: %ld\n", ctx->page.size);
        if (ctx->page.filename)
                htmlf("Content-Disposition: inline; filename=\"%s\"\n",
                      ctx->page.filename);