From: Timo Tseras Date: Thu, 8 May 2014 10:17:41 +0000 (-0700) Subject: Bug 4059: Support redirectors and logging using Squid-2 urlgroup feature X-Git-Tag: SQUID_3_5_0_1~243 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d074f9184059c193db978bf6ca625f776daf9d8e;p=thirdparty%2Fsquid.git Bug 4059: Support redirectors and logging using Squid-2 urlgroup feature --- diff --git a/src/format/ByteCode.h b/src/format/ByteCode.h index 1a407b64ae..9983a4a82f 100644 --- a/src/format/ByteCode.h +++ b/src/format/ByteCode.h @@ -72,6 +72,7 @@ typedef enum { /*LFT_REQUEST_QUERY, */ LFT_REQUEST_VERSION_OLD_2X, LFT_REQUEST_VERSION, + LFT_REQUEST_URLGROUP_OLD_2X, /* request header details pre-adaptation */ LFT_REQUEST_HEADER, diff --git a/src/format/Format.cc b/src/format/Format.cc index 0a13cef827..ce4f41b029 100644 --- a/src/format/Format.cc +++ b/src/format/Format.cc @@ -1136,6 +1136,9 @@ Format::Format::assemble(MemBuf &mb, const AccessLogEntry::Pointer &al, int logS break; #endif + case LFT_REQUEST_URLGROUP_OLD_2X: + assert(LFT_REQUEST_URLGROUP_OLD_2X == 0); // should never happen. + case LFT_NOTE: tmp[0] = fmt->data.header.separator; tmp[1] = '\0'; diff --git a/src/format/Token.cc b/src/format/Token.cc index 98319852b1..606633df00 100644 --- a/src/format/Token.cc +++ b/src/format/Token.cc @@ -93,6 +93,7 @@ static TokenTableEntry TokenTable2C[] = { {"rp", LFT_REQUEST_URLPATH_OLD_31}, /* { "rq", LFT_REQUEST_QUERY }, * / / * the query-string, INCLUDING the leading ? */ {"rv", LFT_REQUEST_VERSION}, + {"rG", LFT_REQUEST_URLGROUP_OLD_2X}, {"(atoi(result)); + char * result = reply.modifiableOther().content(); HelperReply newReply; // BACKWARD COMPATIBILITY 2012-06-15: @@ -142,6 +141,20 @@ redirectHandleReply(void *data, const HelperReply &reply) newReply.result = HelperReply::Okay; newReply.notes.append(&reply.notes); + // check and parse for obsoleted Squid-2 urlgroup feature + if (*result == '!') { + static int urlgroupWarning = 0; + if (!urlgroupWarning++) + debugs(85, DBG_IMPORTANT, "UPGRADE WARNING: URL rewriter using obsolete Squid-2 urlgroup feature needs updating."); + if (char *t = strchr(result+1, '!')) { + *t = '\0'; + newReply.notes.add("urlgroup", result+1); + result = t + 1; + } + } + + const Http::StatusCode status = static_cast(atoi(result)); + if (status == Http::scMovedPermanently || status == Http::scFound || status == Http::scSeeOther @@ -162,7 +175,8 @@ redirectHandleReply(void *data, const HelperReply &reply) // status code is not a redirect code (or does not exist) // treat as a re-write URL request // TODO: validate the URL produced here is RFC 2616 compliant URI - newReply.notes.add("rewrite-url", reply.other().content()); + if (*result) + newReply.notes.add("rewrite-url", result); } void *cbdata;