From: Amos Jeffries Date: Wed, 12 Jul 2023 23:03:32 +0000 (+0000) Subject: Drop ClientHttpRequest::flags::internal (#1414) X-Git-Tag: SQUID_7_0_1~398 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=101694e4332f35dc3b5e4729839fcd2daad858a5;p=thirdparty%2Fsquid.git Drop ClientHttpRequest::flags::internal (#1414) 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. --- diff --git a/src/RequestFlags.h b/src/RequestFlags.h index ceef9213e5..8ef75d462d 100644 --- a/src/RequestFlags.h +++ b/src/RequestFlags.h @@ -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; diff --git a/src/client_side.cc b/src/client_side.cc index 6531396204..1bca92017f 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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 diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 62f6da6b8e..1b4aea7acf 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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(); diff --git a/src/client_side_request.h b/src/client_side_request.h index 7db65d3721..73ba5c8cbb 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -157,7 +157,6 @@ public: struct Flags { bool accel = false; - bool internal = false; bool done_copying = false; } flags;