void FilterUtility::setUpstreamScheme(Http::RequestHeaderMap& headers, bool downstream_secure,
                                      bool upstream_secure) {
  if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.preserve_downstream_scheme")) {
    if (Http::HeaderUtility::schemeIsValid(headers.getSchemeValue())) {
      return;
    }
    if (Http::HeaderUtility::schemeIsValid(headers.getForwardedProtoValue())) {
      headers.setScheme(headers.getForwardedProtoValue());
      return;
    }
  }
  const bool transport_secure =
      Runtime::runtimeFeatureEnabled("envoy.reloadable_features.preserve_downstream_scheme")
          ? downstream_secure
          : upstream_secure;

  if (transport_secure) {
    headers.setReferenceScheme(Http::Headers::get().SchemeValues.Https);
  } else {
    headers.setReferenceScheme(Http::Headers::get().SchemeValues.Http);
  }
}
void FilterUtility::setUpstreamScheme(Http::RequestHeaderMap& headers, bool downstream_secure,
                                      bool upstream_secure) {
  if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.preserve_downstream_scheme")) {
    if (Http::HeaderUtility::schemeIsValid(headers.getSchemeValue())) {
      return;
    }
    if (Http::HeaderUtility::schemeIsValid(headers.getForwardedProtoValue())) {
      headers.setScheme(headers.getForwardedProtoValue());
      return;
    }
  }
  const bool transport_secure =
      Runtime::runtimeFeatureEnabled("envoy.reloadable_features.preserve_downstream_scheme")
          ? downstream_secure
          : upstream_secure;

  if (transport_secure) {
    headers.setReferenceScheme(Http::Headers::get().SchemeValues.Https);
  } else {
    headers.setReferenceScheme(Http::Headers::get().SchemeValues.Http);
  }
}