// Returns an array of header parsers, sorted by specificity. The `specificity_ascend` parameter
getClusterSpecifierPluginByTheProto(const envoy::config::route::v3::ClusterSpecifierPlugin& plugin,
createRedirectConfig(const envoy::config::route::v3::Route& route, Regex::Engine& regex_engine) {
HedgePolicyImpl::HedgePolicyImpl() : initial_requests_(1), hedge_on_per_try_timeout_(false) {}
std::vector<InternalRedirectPredicateSharedPtr> InternalRedirectPolicyImpl::predicates() const {
return absl::InvalidArgumentError(fmt::format("Only one of cluster '{}' or cluster_header '{}' "
trace_sampled_ = config.has_trace_sampled() ? absl::optional<bool>(config.trace_sampled().value())
optional_timeouts_(buildOptionalTimeouts(route.route())), loader_(factory_context.runtime()),
THROW_OR_RETURN_VALUE(buildInternalRedirectPolicy(route.route(), validator, route.name()),
auto_host_rewrite_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(route.route(), auto_host_rewrite, false)),
auto provider_or_error = Envoy::Config::DataSource::DataSourceProvider<std::string>::create(
if (!route.request_headers_to_add().empty() || !route.request_headers_to_remove().empty()) {
if (!route.response_headers_to_add().empty() || !route.response_headers_to_remove().empty()) {
// Returns true if include_vh_rate_limits is explicitly set to true otherwise it defaults to false
// which is similar to VhRateLimitOptions::Override and will only use virtual host rate limits if
const bool enabled = upgrade_config.has_enabled() ? upgrade_config.enabled().value() : true;
auto formatter_or = Envoy::Formatter::FormatterImpl::create(route.route().path_rewrite(), true);
early_data_policy_ = std::make_unique<DefaultEarlyDataPolicy>(/*allow_safe_request*/ true);
bool RouteEntryImplBase::evaluateTlsContextMatch(const StreamInfo::StreamInfo& stream_info) const {
return !redirect_config_->host_redirect_.empty() || !redirect_config_->path_redirect_.empty() ||
if (Http::HeaderUtility::getPortStart(headers.getHostValue()) == absl::string_view::npos) {
/*specificity_ascend=*/vhost_->globalRouteConfig().mostSpecificHeaderMutationsWins())) {
mergeTransforms(transforms, header_parser->getHeaderTransforms(stream_info, do_formatting));
mergeTransforms(transforms, header_parser->getHeaderTransforms(stream_info, do_formatting));
RouteEntryImplBase::loadRuntimeData(const envoy::config::route::v3::RouteMatch& route_match) {
absl::string_view RouteEntryImplBase::formatBody(const Http::RequestHeaderMap& request_headers,
auto filter_metadata = route.metadata().filter_metadata().find("envoy.filters.http.router");
ProtobufMessage::ValidationVisitor& validator, absl::string_view current_route_name) const {
return InternalRedirectPolicyImpl::create(route_config.internal_redirect_policy(), validator,
DecoratorConstPtr RouteEntryImplBase::parseDecorator(const envoy::config::route::v3::Route& route) {
return cluster_specifier_plugin_->route(shared_from_this(), headers, stream_info, random_value);
absl::Status RouteEntryImplBase::validateClusters(const Upstream::ClusterManager& cm) const {
absl::optional<bool> RouteEntryImplBase::filterDisabled(absl::string_view config_name) const {
finalizePathHeaderForRedirect(headers, path_matcher_->uriTemplate(), insert_envoy_original_path);
path_matcher_(Matchers::PathMatcher::createPrefix(route.match().prefix(), !case_sensitive(),
return currentUrlPathAfterRewriteWithMatchedPath(headers, context, stream_info, matcher());
const absl::string_view path = Http::PathUtil::removeQueryAndFragment(headers.getPathValue());
const absl::string_view path = Http::PathUtil::removeQueryAndFragment(headers.getPathValue());
const absl::string_view path = Http::PathUtil::removeQueryAndFragment(headers.getPathValue());
Server::Configuration::CommonFactoryContext& context, const VirtualClusterStatNames& stat_names)
const CommonConfig& CommonVirtualHostImpl::routeConfig() const { return *global_route_config_; }
absl::optional<bool> CommonVirtualHostImpl::filterDisabled(absl::string_view config_name) const {
auto ret = std::unique_ptr<RouteMatcher>{new RouteMatcher(route_config, global_route_config,
const VirtualHostImpl* RouteMatcher::findVirtualHost(const Http::RequestHeaderMap& headers) const {
// If 'ignore_port_in_host_matching' is set, ignore the port number in the host header(if any).
VirtualHostRoute RouteMatcher::route(const RouteCallback& cb, const Http::RequestHeaderMap& headers,
route_result.route = virtual_host->getRouteFromEntries(cb, headers, stream_info, random_value);
ignore_path_parameters_in_path_matching_(config.ignore_path_parameters_in_path_matching()) {
// Initialize all cluster specifier plugins before creating route matcher. Because the route may
if (!config.request_headers_to_add().empty() || !config.request_headers_to_remove().empty()) {
if (!config.response_headers_to_add().empty() || !config.response_headers_to_remove().empty()) {
VirtualHostRoute ConfigImpl::route(const RouteCallback& cb, const Http::RequestHeaderMap& headers,
RouteMatchActionFactory::createAction(const Protobuf::Message& config, RouteActionContext& context,