about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorLars Hjemli2008-09-15 21:47:14 +0200
committerLars Hjemli2008-09-15 21:47:14 +0200
commit91fd1eca07f9e48109e8acebc0a92dc4b12ecb50 (patch)
treedb8c084d617c8e02899f358a42631646b7c1b766
parentUpdate Makefile to use GIT-1.6.0.1 (diff)
parentuse Host: header to generate cgit_hosturl (diff)
downloadcgit-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.tar.gz
cgit-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.zip
Merge branch 'ew/http_host'
* ew/http_host:
  use Host: header to generate cgit_hosturl
-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
@@ -38,14 +38,19 @@ char *cgit_hosturl()
38{ 38{
39 char *host, *port; 39 char *host, *port;
40 40
41 host = getenv("SERVER_NAME"); 41 host = getenv("HTTP_HOST");
42 if (!host) 42 if (host) {
43 return NULL;
44 port = getenv("SERVER_PORT");
45 if (port && atoi(port) != 80)
46 host = xstrdup(fmt("%s:%d", host, atoi(port)));
47 else
48 host = xstrdup(host); 43 host = xstrdup(host);
44 } else {
45 host = getenv("SERVER_NAME");
46 if (!host)
47 return NULL;
48 port = getenv("SERVER_PORT");
49 if (port && atoi(port) != 80)
50 host = xstrdup(fmt("%s:%d", host, atoi(port)));
51 else
52 host = xstrdup(host);
53 }
49 return host; 54 return host;
50} 55}
51 56