* When the -f option is specified, honor X-Forwarded-Host: in addition
authorArt Cancro <ajc@citadel.org>
Mon, 30 Jan 2006 17:11:01 +0000 (17:11 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 30 Jan 2006 17:11:01 +0000 (17:11 +0000)
  to X-Forwarded-For: headers.  This helps GroupDAV along.

webcit/ChangeLog
webcit/README.txt
webcit/groupdav_main.c
webcit/webcit.c

index 01a426bc783e0431d0b3fb03b6afb6e49d863b77..0233735b7faecd8a8da7eee70324b17190dec9e0 100644 (file)
@@ -1,5 +1,9 @@
 $Id$
 
+Mon Jan 30 12:09:00 EST 2006 ajc
+* When the -f option is specified, honor X-Forwarded-Host: in addition
+  to X-Forwarded-For: headers.  This helps GroupDAV along.
+
 Mon Jan 30 00:14:06 EST 2006 ajc
 * HTML messages are now encoded as "Quoted-Printable" before being
   transmitted to the server.  New utility function text_to_server_qp()
index e35422e4553a949e9d5d74f441de37aa30e0988e..a530f5e29fb45b61b06bf76b31332ca9c4195733 100644 (file)
@@ -125,7 +125,10 @@ the "webserver" program:
      "X-Forwarded-For:" HTTP headers which may be added if your WebCit service
      is sitting behind a front end proxy.  This will allow users in your "Who
      is online?" list to appear as connecting from their actual host address
-     instead of the address of the proxy.
+     instead of the address of the proxy.  In addition, the
+     "X-Forwarded-Host:" header from the front end proxy will also be honored,
+     which will help to make automatically generated absolute URL's (for
+     things like GroupDAV and mailing list subscriptions) correct.
  
   -> remotehost: the name or IP address of the host on which your Citadel
      server is running.  The default is "localhost".
index 46d467ec3a03834db0994374af733aa0107de015..dd3fd74688bcc0ea3413d93a397ba9dcbb44c2f5 100644 (file)
@@ -127,10 +127,15 @@ void groupdav_main(struct httprequest *req,
 
        for (rptr=req; rptr!=NULL; rptr=rptr->next) {
                /* lprintf(9, "< %s\n", rptr->line); */
+
+               /*
+                * We don't appear to need this; it was already done in webcit.c
                if (!strncasecmp(rptr->line, "Host: ", 6)) {
                         safestrncpy(WC->http_host, &rptr->line[6],
                                sizeof WC->http_host);
                 }
+               */
+
                if (!strncasecmp(rptr->line, "If-Match: ", 10)) {
                         safestrncpy(dav_ifmatch, &rptr->line[10],
                                sizeof dav_ifmatch);
index 1d9610c41c6aeb6f0c73dbeab96e2a3b5a383b45..37289dea89ba649811642f70d8c9f0e82f4afa2b 100644 (file)
@@ -1089,6 +1089,7 @@ void session_loop(struct httprequest *req)
 
        while (hptr != NULL) {
                safestrncpy(buf, hptr->line, sizeof buf);
+               lprintf(9, "HTTP HEADER: %s\n", buf);
                hptr = hptr->next;
 
                if (!strncasecmp(buf, "Cookie: webcit=", 15)) {
@@ -1112,8 +1113,15 @@ void session_loop(struct httprequest *req)
                else if (!strncasecmp(buf, "User-agent: ", 12)) {
                        safestrncpy(user_agent, &buf[12], sizeof user_agent);
                }
+               else if (!strncasecmp(buf, "X-Forwarded-Host: ", 18)) {
+                       if (follow_xff) {
+                               safestrncpy(WC->http_host, &buf[18], sizeof WC->http_host);
+                       }
+               }
                else if (!strncasecmp(buf, "Host: ", 6)) {
-                       safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
+                       if (strlen(WC->http_host) == 0) {
+                               safestrncpy(WC->http_host, &buf[6], sizeof WC->http_host);
+                       }
                }
                else if (!strncasecmp(buf, "X-Forwarded-For: ", 17)) {
                        safestrncpy(browser_host, &buf[17], sizeof browser_host);