]> code.citadel.org Git - citadel.git/blobdiff - webcit/context_loop.c
Handle X-Forwarded-Host: properly
[citadel.git] / webcit / context_loop.c
index a358545e989c36ccbc46ce5be28f495cf4aa46a1..2dd63c9a2efdb551193577e536d64489caa7b04a 100644 (file)
@@ -671,24 +671,20 @@ void Header_HandleUserAgent(StrBuf *Line, ParsedHttpHdrs *hdr)
 
 void Header_HandleHost(StrBuf *Line, ParsedHttpHdrs *hdr)
 {
-       if ((follow_xff) && (hdr->HR.http_host != NULL)) {
-               return;
-       }
-       else {
-               hdr->HR.http_host = Line;
-               if (site_prefix == NULL) {
-                       site_prefix = NewStrBuf();
-                       StrBufAppendPrintf(site_prefix, "%s://", (is_https ? "https" : "http") );
-                       StrBufAppendBuf(site_prefix, Line, 0);
-                       lprintf(CTDL_DEBUG, "\033[33m [%s] \033[0m\n", ChrPtr(site_prefix));
-               }
+       if (site_prefix == NULL) {
+               site_prefix = NewStrBuf();
+               StrBufAppendPrintf(site_prefix, "%s://", (is_https ? "https" : "http") );
+               StrBufAppendBuf(site_prefix, Line, 0);
        }
 }
 
 void Header_HandleXFFHost(StrBuf *Line, ParsedHttpHdrs *hdr)
 {
-       if (follow_xff)
-               hdr->HR.http_host = Line;
+       if ( (follow_xff) && (site_prefix == NULL)) {
+               site_prefix = NewStrBuf();
+               StrBufAppendPrintf(site_prefix, "http://");     /* this is naive; do something about it */
+               StrBufAppendBuf(site_prefix, Line, 0);
+       }
 }