]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Drop ClientHttpRequest::flags::internal (#1414)
authorAmos Jeffries <yadij@users.noreply.github.com>
Wed, 12 Jul 2023 23:03:32 +0000 (23:03 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Thu, 13 Jul 2023 07:33:07 +0000 (07:33 +0000)
This flag is unnecessary when `HttpRequest::flags::internal`
is available, which is almost all code needing to detect
internal traffic.

The exception to this is parsing prior to HttpRequest
creation, which already uses internalCheck() API instead.

src/RequestFlags.h
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.h

index ceef9213e519df88ab4e8a48b10b07def0809583..8ef75d462ddf4a41f3d0c2cd839762b86f4591a5 100644 (file)
@@ -75,7 +75,6 @@ public:
 
     /// whether the request targets a /squid-internal- resource (e.g., a MIME
     /// icon or a cache manager page) served by this Squid instance
-    /// \sa ClientHttpRequest::flags.internal
     /// TODO: Rename to avoid a false implication that this flag is true for
     /// requests for /squid-internal- resources served by other Squid instances.
     bool internal = false;
index 6531396204548b8ebac343b0196d64068a242431..1bca92017f7fd4202dec8a5a739f0deb4c58964c 100644 (file)
@@ -1403,11 +1403,9 @@ ConnStateData::parseHttpRequest(const Http1::RequestParserPointer &hp)
 
     } else if (internalCheck(hp->requestUri())) { // NP: only matches relative-URI
         /* internal URL mode */
-        /* prepend our name & port */
+        // XXX: By prepending our name and port, we create an absolute URL
+        // that may mismatch the (yet unparsed) Host header in the request.
         http->uri = xstrdup(internalLocalUri(nullptr, hp->requestUri()));
-        // We just re-wrote the URL. Must replace the Host: header.
-        //  But have not parsed there yet!! flag for local-only handling.
-        http->flags.internal = true;
 
     } else if (port->flags.accelSurrogate) {
         /* accelerator mode */
@@ -1640,13 +1638,13 @@ clientProcessRequest(ConnStateData *conn, const Http1::RequestParserPointer &hp,
     if (internalCheck(request->url.path())) {
         if (internalHostnameIs(request->url.host()) && request->url.port() == getMyPort()) {
             debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true));
-            http->flags.internal = true;
+            request->flags.internal = true;
         } else if (Config.onoff.global_internal_static && internalStaticCheck(request->url.path())) {
             debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true) << " (global_internal_static on)");
             request->url.setScheme(AnyP::PROTO_HTTP, "http");
             request->url.host(internalHostname());
             request->url.port(getMyPort());
-            http->flags.internal = true;
+            request->flags.internal = true;
             http->setLogUriToRequestUri();
         } else
             debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->url.authority(true) << " (not this proxy)");
@@ -1655,8 +1653,6 @@ clientProcessRequest(ConnStateData *conn, const Http1::RequestParserPointer &hp,
             request->flags.disableCacheUse("cache manager URL");
     }
 
-    request->flags.internal = http->flags.internal;
-
     if (!isFtp) {
         // XXX: for non-HTTP messages instantiate a different Http::Message child type
         // for now Squid only supports HTTP requests
index 62f6da6b8e05e319f1488e9064ca9e56a38ba42e..1b4aea7acff64e0ab77cec089b0d3bac604b5540 100644 (file)
@@ -611,7 +611,7 @@ clientReplyContext::cacheHit(const StoreIOBuffer result)
         http->updateLoggingTags(LOG_TCP_MISS);
         processMiss();
         return;
-    } else if (!http->flags.internal && refreshCheckHTTP(e, r)) {
+    } else if (!r->flags.internal && refreshCheckHTTP(e, r)) {
         debugs(88, 5, "clientCacheHit: in refreshCheck() block");
         /*
          * We hold a stale copy; it needs to be validated
@@ -834,7 +834,7 @@ clientReplyContext::blockedHit() const
     if (!Config.accessList.sendHit)
         return false; // hits are not blocked by default
 
-    if (http->flags.internal)
+    if (http->request->flags.internal)
         return false; // internal content "hits" cannot be blocked
 
     const auto &rep = http->storeEntry()->mem().freshestReply();
index 7db65d3721a7ea2ddc45c9765cd3f1f259db4be5..73ba5c8cbbe0a886cee7885cb9dd5b4f612bf862 100644 (file)
@@ -157,7 +157,6 @@ public:
 
     struct Flags {
         bool accel = false;
-        bool internal = false;
         bool done_copying = false;
     } flags;