]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bugzilla #423: Via: applys to responses as well as requests
authorhno <>
Sun, 1 Sep 2002 19:46:55 +0000 (19:46 +0000)
committerhno <>
Sun, 1 Sep 2002 19:46:55 +0000 (19:46 +0000)
Merged over updated Via support from the rproxy branch.

src/cf.data.pre
src/client_side.cc
src/http.cc
src/structs.h

index df63c8a1bc33030da5b60e34349132ce7028e6f2..91ba0957c98a5fe8bfb854bbeee303c6a249fa72 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.278 2002/08/28 04:24:07 wessels Exp $
+# $Id: cf.data.pre,v 1.279 2002/09/01 13:46:55 hno Exp $
 #
 #
 # SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -2733,6 +2733,15 @@ DOC_START
        reduced memory thrashing in your malloc library.
 DOC_END
 
+NAME: via
+COMMENT: on|off
+DEFAULT: on
+LOC: Config.onoff.via
+DOC_START
+       If set (default), Squid will include a Via header in requests and
+       replies as required by RFC2616.
+DOC_END
+
 NAME: forwarded_for
 COMMENT: on|off
 TYPE: onoff
index f57334fce07218e1f9e8fc8a4ad858956694bd60..02f7195ac784d0bb2b65e6ef3e621f5f714bced9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.589 2002/08/28 16:10:57 wessels Exp $
+ * $Id: client_side.cc,v 1.590 2002/09/01 13:46:55 hno Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1231,6 +1231,18 @@ clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep)
        debug(33, 3) ("clientBuildReplyHeader: can't keep-alive, unknown body size\n");
        request->flags.proxy_keepalive = 0;
     }
+    /* Append Via */
+    {
+       LOCAL_ARRAY(char, bbuf, MAX_URL + 32);
+       String strVia = httpHeaderGetList(hdr, HDR_VIA);
+       snprintf(bbuf, sizeof(bbuf), "%d.%d %s",
+           rep->sline.version.major,
+           rep->sline.version.minor, ThisCache);
+       strListAdd(&strVia, bbuf, ',');
+       httpHeaderDelById(hdr, HDR_VIA);
+       httpHeaderPutStr(hdr, HDR_VIA, strBuf(strVia));
+       stringClean(&strVia);
+    }
     /* Signal keep-alive if needed */
     httpHeaderPutStr(hdr,
        http->flags.accel ? HDR_CONNECTION : HDR_PROXY_CONNECTION,
index b020126866b2f265f79cf54be991317395e1ccca..7d091bfb2e0016dcb8e40cb1523815aaf26c4f98 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.388 2002/06/06 15:11:31 hno Exp $
+ * $Id: http.cc,v 1.389 2002/09/01 13:46:56 hno Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -730,7 +730,6 @@ httpBuildRequestHeader(request_t * request,
     String strConnection = StringNull;
     const HttpHeader *hdr_in = &orig_request->header;
     const HttpHeaderEntry *e;
-    String strVia;
     String strFwd;
     HttpHeaderPos pos = HttpHeaderInitPos;
     httpHeaderInit(hdr_out, hoRequest);
@@ -797,9 +796,13 @@ httpBuildRequestHeader(request_t * request,
                    httpHeaderPutInt(hdr_out, HDR_MAX_FORWARDS, hops - 1);
            }
            break;
+       case HDR_VIA:
+           /* If Via is disabled then forward any received header as-is */
+           if (!Config.onoff.via)
+               httpHeaderAddEntry(hdr_out, httpHeaderEntryClone(e));
+           break;
        case HDR_PROXY_CONNECTION:
        case HDR_CONNECTION:
-       case HDR_VIA:
        case HDR_X_FORWARDED_FOR:
        case HDR_CACHE_CONTROL:
            /* append these after the loop if needed */
@@ -811,14 +814,15 @@ httpBuildRequestHeader(request_t * request,
     }
 
     /* append Via */
-    strVia = httpHeaderGetList(hdr_in, HDR_VIA);
-    snprintf(bbuf, BBUF_SZ, "%d.%d %s",
-       orig_request->http_ver.major,
-       orig_request->http_ver.minor, ThisCache);
-    strListAdd(&strVia, bbuf, ',');
-    httpHeaderPutStr(hdr_out, HDR_VIA, strBuf(strVia));
-    stringClean(&strVia);
-
+    if (Config.onoff.via) {
+       String strVia = httpHeaderGetList(hdr_in, HDR_VIA);
+       snprintf(bbuf, BBUF_SZ, "%d.%d %s",
+           orig_request->http_ver.major,
+           orig_request->http_ver.minor, ThisCache);
+       strListAdd(&strVia, bbuf, ',');
+       httpHeaderPutStr(hdr_out, HDR_VIA, strBuf(strVia));
+       stringClean(&strVia);
+    }
     /* append X-Forwarded-For */
     strFwd = httpHeaderGetList(hdr_in, HDR_X_FORWARDED_FOR);
     strListAdd(&strFwd, (cfd < 0 ? "unknown" : fd_table[cfd].ipaddr), ',');
index 303506766f56b0759f3fe5c341eff26359050d9c..ec5c190db46de3c308384aaa680dadaa0fcfca9b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.425 2002/08/28 04:24:07 wessels Exp $
+ * $Id: structs.h,v 1.426 2002/09/01 13:46:56 hno Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -589,6 +589,7 @@ struct _SquidConfig {
        int vary_ignore_expire;
        int pipeline_prefetch;
        int check_hostnames;
+       int via;
     } onoff;
     acl *aclList;
     struct {