From: hno <> Date: Sun, 1 Sep 2002 19:46:55 +0000 (+0000) Subject: Bugzilla #423: Via: applys to responses as well as requests X-Git-Tag: SQUID_3_0_PRE1~798 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=736cb6aab6982d94c8f283c5615a4d4e32973607;p=thirdparty%2Fsquid.git Bugzilla #423: Via: applys to responses as well as requests Merged over updated Via support from the rproxy branch. --- diff --git a/src/cf.data.pre b/src/cf.data.pre index df63c8a1bc..91ba0957c9 100644 --- a/src/cf.data.pre +++ b/src/cf.data.pre @@ -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 diff --git a/src/client_side.cc b/src/client_side.cc index f57334fce0..02f7195ac7 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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, diff --git a/src/http.cc b/src/http.cc index b020126866..7d091bfb2e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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), ','); diff --git a/src/structs.h b/src/structs.h index 303506766f..ec5c190db4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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 {