all repos — cgit @ 91fd1eca07f9e48109e8acebc0a92dc4b12ecb50

a hyperfast web frontend for git written in c

Merge branch 'ew/http_host'

* ew/http_host:
  use Host: header to generate cgit_hosturl
Lars Hjemli hjemli@gmail.com
Mon, 15 Sep 2008 21:47:14 +0200
commit

91fd1eca07f9e48109e8acebc0a92dc4b12ecb50

parent

b28765135dd6f52635977454eaf95d0e6c7e7271

1 files changed, 12 insertions(+), 7 deletions(-)

jump to
M ui-shared.cui-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; }