]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup of how "httpd_accel_port virtual" is handled. Now httpd_accel_port
authorhno <>
Mon, 12 Feb 2001 03:06:15 +0000 (03:06 +0000)
committerhno <>
Mon, 12 Feb 2001 03:06:15 +0000 (03:06 +0000)
is always (for accelerated request) used if it is set, and if virtual then
the port number is retreived from
a) Host header (when httpd_accel_uses_host_header is on)
b) Transparent redirection/NAT lookup
c) Local endpoint of the socket

Previosly is was a mix where some always overrode httpd_accel_port, and
in some cases virtual was even ignored causing a port number of 0..

src/client_side.cc

index bf75c22dc1203e301e7afbffad27e0b1339634c3..79f7ed686438ec58c36b000c28ac52f0b37654b3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.525 2001/02/09 19:35:11 hno Exp $
+ * $Id: client_side.cc,v 1.526 2001/02/11 20:06:15 hno Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -2436,8 +2436,12 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
     else if (Config2.Accel.on && *url == '/') {
        /* prepend the accel prefix */
        if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) {
-           int vport = (int) Config.Accel.port;
+           int vport;
            char *q;
+           if (vport_mode)
+               vport = (int) ntohs(http->conn->me.sin_port);
+           else
+               vport = (int) Config.Accel.port;
            /* If a Host: header was specified, use it to build the URL 
             * instead of the one in the Config file. */
            /*
@@ -2450,7 +2454,8 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
            strtok(t, " /;@");
            if ((q = strchr(t, ':'))) {
                *q++ = '\0';
-               vport = atoi(q);
+               if (vport_mode)
+                   vport = atoi(q);
            }
            url_sz = strlen(url) + 32 + Config.appendDomainLen +
                strlen(t);
@@ -2503,6 +2508,8 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
                        inet_ntoa(http->conn->me.sin_addr),
                        vport, url);
            } else
+               if (vport_mode)
+                   vport = natLookup.nl_realport;
                snprintf(http->uri, url_sz, "http://%s:%d%s",
                    inet_ntoa(natLookup.nl_realip),
                    vport, url);
@@ -2511,6 +2518,8 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
            /* If the call fails the address structure will be unchanged */
            getsockopt(conn->fd, SOL_IP, SO_ORIGINAL_DST, &conn->me, &sock_sz);
            debug(33, 5) ("parseHttpRequest: addr = %s", inet_ntoa(conn->me.sin_addr));
+           if (vport_mode)
+               vport = (int) ntohs(http->conn->me.sin_port);
 #endif
            snprintf(http->uri, url_sz, "http://%s:%d%s",
                inet_ntoa(http->conn->me.sin_addr),