about summary refs log tree commit diff
path: root/ui-shared.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2008-09-15 21:47:14 +0200
committerLars Hjemli <hjemli@gmail.com>2008-09-15 21:47:14 +0200
commit91fd1eca07f9e48109e8acebc0a92dc4b12ecb50 (patch)
treedb8c084d617c8e02899f358a42631646b7c1b766 /ui-shared.c
parentUpdate Makefile to use GIT-1.6.0.1 (diff)
parentuse Host: header to generate cgit_hosturl (diff)
downloadcgit-pink-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.tar.gz
cgit-pink-91fd1eca07f9e48109e8acebc0a92dc4b12ecb50.zip
Merge branch 'ew/http_host'
* ew/http_host:
  use Host: header to generate cgit_hosturl
Diffstat (limited to 'ui-shared.c')
-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()
 {
 	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;
 }