]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
add Host: header to requests
authorwessels <>
Tue, 15 Oct 1996 11:45:36 +0000 (11:45 +0000)
committerwessels <>
Tue, 15 Oct 1996 11:45:36 +0000 (11:45 +0000)
src/http.cc

index 7ab43486b44a45298c6af6afcefa80e7eeb0a37f..4e85e3628ad568885ea60164222dfeaa321216b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.83 1996/10/11 23:11:12 wessels Exp $
+ * $Id: http.cc,v 1.84 1996/10/15 05:45:36 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -570,6 +570,7 @@ httpSendRequest(int fd, void *data)
     char *Method = RequestMethodStr[req->method];
     int buftype = 0;
     StoreEntry *entry = httpState->entry;
+    int saw_host = 0;
 
     debug(11, 5, "httpSendRequest: FD %d: httpState %p.\n", fd, httpState);
     buflen = strlen(Method) + strlen(req->urlpath);
@@ -604,6 +605,8 @@ httpSendRequest(int fd, void *data)
        for (t = strtok(xbuf, crlf); t; t = strtok(NULL, crlf)) {
            if (strncasecmp(t, "Connection:", 11) == 0)
                continue;
+           if (strncasecmp(t, "Host:", 5) == 0)
+               saw_host = 1;
            if (len + (int) strlen(t) > buflen - 10)
                continue;
            strcat(buf, t);
@@ -636,6 +639,14 @@ httpSendRequest(int fd, void *data)
        len += strlen(ybuf);
        put_free_4k_page(ybuf);
     }
+    /* Add Host: header */
+    if (!saw_host) {
+       ybuf = get_free_4k_page();
+       sprintf(ybuf, "Host: %s\r\n", req->host);
+       strcat(buf, ybuf);
+       len += strlen(ybuf);
+       put_free_4k_page(ybuf);
+    }
     strcat(buf, crlf);
     len += 2;
     if (post_buf) {