]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 4059: Support redirectors and logging using Squid-2 urlgroup feature
authorTimo Tseras <timo.teras@iki.fi>
Thu, 8 May 2014 10:17:41 +0000 (03:17 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 8 May 2014 10:17:41 +0000 (03:17 -0700)
src/format/ByteCode.h
src/format/Format.cc
src/format/Token.cc
src/redirect.cc

index 1a407b64aebcbdbbacb1c0f03aa1d62d2ce26152..9983a4a82fdd144133b7532d2ea083a01b273e37 100644 (file)
@@ -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,
index 0a13cef827e8ef642d52b3a99116cbab02cf692c..ce4f41b029a837da59e921805ab3fc89694ebd85 100644 (file)
@@ -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';
index 98319852b140aff10cc7ba48518e30bf12cf8604..606633df00a897f1f7cf58ca148efdc31ce680b4 100644 (file)
@@ -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},
 
     {"<rm", LFT_SERVER_REQ_METHOD},
     {"<ru", LFT_SERVER_REQ_URI},
@@ -541,6 +542,12 @@ done:
         break;
 #endif
 
+    case LFT_REQUEST_URLGROUP_OLD_2X:
+        debugs(46, DBG_PARSE_NOTE(DBG_IMPORTANT), "WARNING: The \"rG\" formatting code is deprecated. Use \"note{urlgroup}\" instead.");
+        type = LFT_NOTE;
+        data.header.header = xstrdup("urlgroup");
+        break;
+
     default:
         break;
     }
index 770a8af2ae9400448d955d9a6e782742e69bd6a8..267568091b548b70db5d318dd38fec8c0bd81616 100644 (file)
@@ -131,8 +131,7 @@ redirectHandleReply(void *data, const HelperReply &reply)
                  * At this point altering the helper buffer in that way is not harmful, but annoying.
                  * When Bug 1961 is resolved and urlParse has a const API, this needs to die.
                  */
-                const char * result = reply.other().content();
-                const Http::StatusCode status = static_cast<Http::StatusCode>(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<Http::StatusCode>(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;