summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2008-09-15 19:47:14 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2008-09-15 19:47:14 (UTC)
commit91fd1eca07f9e48109e8acebc0a92dc4b12ecb50 (patch) (side-by-side diff)
treedb8c084d617c8e02899f358a42631646b7c1b766
parentb28765135dd6f52635977454eaf95d0e6c7e7271 (diff)
parent9c931b1e6e68f8dc891a5653035c3d70038ae3c0 (diff)
downloadcgit-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.zip
cgit-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.tar.gz
cgit-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.tar.bz2
Merge branch 'ew/http_host'
* ew/http_host: use Host: header to generate cgit_hosturl
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-shared.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/ui-shared.c b/ui-shared.c
index 4818e70..c23bc75 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -17,56 +17,61 @@ const char cgit_doctype[] =
static char *http_date(time_t t)
{
static char day[][4] =
{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
static char month[][4] =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Now", "Dec"};
struct tm *tm = gmtime(&t);
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
void cgit_print_error(char *msg)
{
html("<div class='error'>");
html_txt(msg);
html("</div>\n");
}
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;
}
char *cgit_rooturl()
{
if (ctx.cfg.virtual_root)
return fmt("%s/", ctx.cfg.virtual_root);
else
return ctx.cfg.script_name;
}
char *cgit_repourl(const char *reponame)
{
if (ctx.cfg.virtual_root) {
return fmt("%s/%s/", ctx.cfg.virtual_root, reponame);
} else {
return fmt("?r=%s", reponame);
}
}
char *cgit_fileurl(const char *reponame, const char *pagename,
const char *filename, const char *query)
{
char *tmp;