Loading src/http/HttpProxyServer.cpp +10 −7 Changes for src/http/HttpProxyServer.cpp: 10 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -293,10 +293,13 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int if (auto *v = hostHdr->getfirstValue()) requestHost = normalizeHost(v->getvalue()); } // Prefer an exact domain match over a wildcard ("*"/empty = any Host) one regardless // of path length, so e.g. "example.com" + "/" outranks "*" + "/app" for a request to // example.com/app -- only among routes of the same domain-specificity does the longer // pathPrefix win. // The longer/more specific pathPrefix wins outright, regardless of domain // specificity -- e.g. "*" + "/blog" outranks "example.com" + "/" for a request to // example.com/blog, since "/blog" is the more specific match a config author clearly // meant to carve out of that domain's catch-all. Domain specificity is only a // tiebreak between routes whose pathPrefix ties in length (most commonly two // catch-all "/" routes, one for a specific domain and one wildcard -- the specific // one should win for its own domain there). const store::HttpRouteRecord *best = nullptr; bool bestIsDomainSpecific = false; auto routes = _configStore.listHttpRoutes(); Loading @@ -305,9 +308,9 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int bool wildcard = route.domain.empty() || route.domain == "*"; if (!wildcard && normalizeHost(route.domain) != requestHost) continue; bool domainSpecific = !wildcard; bool better = !best || (domainSpecific && !bestIsDomainSpecific) || (domainSpecific == bestIsDomainSpecific && route.pathPrefix.size() > best->pathPrefix.size()); bool better = !best || route.pathPrefix.size() > best->pathPrefix.size() || (route.pathPrefix.size() == best->pathPrefix.size() && domainSpecific && !bestIsDomainSpecific); if (better) { best = &route; bestIsDomainSpecific = domainSpecific; Loading Loading
src/http/HttpProxyServer.cpp +10 −7 Changes for src/http/HttpProxyServer.cpp: 10 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -293,10 +293,13 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int if (auto *v = hostHdr->getfirstValue()) requestHost = normalizeHost(v->getvalue()); } // Prefer an exact domain match over a wildcard ("*"/empty = any Host) one regardless // of path length, so e.g. "example.com" + "/" outranks "*" + "/app" for a request to // example.com/app -- only among routes of the same domain-specificity does the longer // pathPrefix win. // The longer/more specific pathPrefix wins outright, regardless of domain // specificity -- e.g. "*" + "/blog" outranks "example.com" + "/" for a request to // example.com/blog, since "/blog" is the more specific match a config author clearly // meant to carve out of that domain's catch-all. Domain specificity is only a // tiebreak between routes whose pathPrefix ties in length (most commonly two // catch-all "/" routes, one for a specific domain and one wildcard -- the specific // one should win for its own domain there). const store::HttpRouteRecord *best = nullptr; bool bestIsDomainSpecific = false; auto routes = _configStore.listHttpRoutes(); Loading @@ -305,9 +308,9 @@ void HttpProxyController::RequestEvent(libhttppp::HttpRequest &curreq, const int bool wildcard = route.domain.empty() || route.domain == "*"; if (!wildcard && normalizeHost(route.domain) != requestHost) continue; bool domainSpecific = !wildcard; bool better = !best || (domainSpecific && !bestIsDomainSpecific) || (domainSpecific == bestIsDomainSpecific && route.pathPrefix.size() > best->pathPrefix.size()); bool better = !best || route.pathPrefix.size() > best->pathPrefix.size() || (route.pathPrefix.size() == best->pathPrefix.size() && domainSpecific && !bestIsDomainSpecific); if (better) { best = &route; bestIsDomainSpecific = domainSpecific; Loading