Repository: envoyproxy/envoy
File: source/extensions/filters/http/dynamic_forward_proxy/proxy_filter.cc (C++)

Code before:
    // even if addresses don't change where this does induce DNS latency if there hasn't been a
    // network change if the endpoint hasn't been referenced recently, but also guarantees there
    // will be a DNS resolution relevant to the current network and is more consistent with other
    // vetted and tested client stacks and resolution any time an endpoint becomes unreachable.
    //
    // If this runtime guard proves useful for Envoy Mobile, it will be replaced
    // either with a permanent knob or non-reloadable runtime guard (see TODO in
    // runtime_features.cc)
    auto dfp_lb =
        dynamic_cast<Extensions::Common::DynamicForwardProxy::DfpLb*>(&cluster->loadBalancer());
    if (dfp_lb) {
      std::string hostname = Common::DynamicForwardProxy::DnsHostInfo::normalizeHostForDfp(
          headers.getHostValue(), default_port);
      auto host = dfp_lb->findHostByName(hostname);
      if (host && !host->used()) {
        force_cache_refresh = true;
      }
    }
  }

  latchTime(decoder_callbacks_, DNS_START);
  const bool is_proxying = isProxying();
  if (headers.Host()->value().getStringView().empty()) {
    decoder_callbacks_->sendLocalReply(Http::Code::BadRequest,
                                        ResponseStrings::get().EmptyHostHeader, nullptr,
                                        absl::nullopt, RcDetails::get().EmptyHostHeader);
    return Http::FilterHeadersStatus::StopIteration;
  }

  // Get host value from the request headers.
  const auto host_attributes =
      Http::Utility::parseAuthority(headers.Host()->value().getStringView());
  // For IPv6 numeric addresses, use a copy with square brackets added around the host.
  // For any other address type just use the existing unmodified host string.
  std::string host_str;
  absl::string_view host;
  if (host_attributes.is_ip_address_ && absl::StrContains(host_attributes.host_, ":")) {
    host_str = absl::StrCat("[", host_attributes.host_, "]");
    host = host_str;
  } else {
    host = host_attributes.host_;
  }
  uint16_t port = host_attributes.port_.value_or(default_port);

  // Apply filter state overrides for host and port.
  uint32_t port_u32 = port;
  applyFilterStateOverrides(host, port_u32, decoder_callbacks_,
                            config_->allowDynamicHostFromFilterState());
  port = port_u32;

  auto [status_, handle_, host_info_] = config_->cache().loadDnsCacheEntryWithForceRefresh(

Review comment (bug):
Looks like format is not happy :)

```suggestion
                                       ResponseStrings::get().EmptyHostHeader, nullptr,
                                       absl::nullopt, RcDetails::get().EmptyHostHeader);
```

Code after:
    // even if addresses don't change where this does induce DNS latency if there hasn't been a
    // network change if the endpoint hasn't been referenced recently, but also guarantees there
    // will be a DNS resolution relevant to the current network and is more consistent with other
    // vetted and tested client stacks and resolution any time an endpoint becomes unreachable.
    //
    // If this runtime guard proves useful for Envoy Mobile, it will be replaced
    // either with a permanent knob or non-reloadable runtime guard (see TODO in
    // runtime_features.cc)
    auto dfp_lb =
        dynamic_cast<Extensions::Common::DynamicForwardProxy::DfpLb*>(&cluster->loadBalancer());
    if (dfp_lb) {
      std::string hostname = Common::DynamicForwardProxy::DnsHostInfo::normalizeHostForDfp(
          headers.getHostValue(), default_port);
      auto host = dfp_lb->findHostByName(hostname);
      if (host && !host->used()) {
        force_cache_refresh = true;
      }
    }
  }

  latchTime(decoder_callbacks_, DNS_START);
  const bool is_proxying = isProxying();
  if (headers.Host()->value().getStringView().empty()) {
    decoder_callbacks_->sendLocalReply(Http::Code::BadRequest,
                                       ResponseStrings::get().EmptyHostHeader, nullptr,
                                       absl::nullopt, RcDetails::get().EmptyHostHeader);
    return Http::FilterHeadersStatus::StopIteration;
  }

  // Get host value from the request headers.
  const auto host_attributes =
      Http::Utility::parseAuthority(headers.Host()->value().getStringView());
  // For IPv6 numeric addresses, use a copy with square brackets added around the host.
  // For any other address type just use the existing unmodified host string.
  std::string host_str;
  absl::string_view host;
  if (host_attributes.is_ip_address_ && absl::StrContains(host_attributes.host_, ":")) {
    host_str = absl::StrCat("[", host_attributes.host_, "]");
    host = host_str;
  } else {
    host = host_attributes.host_;
  }
  uint16_t port = host_attributes.port_.value_or(default_port);

  // Apply filter state overrides for host and port.
  uint32_t port_u32 = port;
  applyFilterStateOverrides(host, port_u32, decoder_callbacks_,
                            config_->allowDynamicHostFromFilterState());
  port = port_u32;

  auto [status_, handle_, host_info_] = config_->cache().loadDnsCacheEntryWithForceRefresh(