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;
    }
    // After all the changes in https://github.com/envoyproxy/envoy/issues/14587
    // this path should only occur if a buggy filter has removed the :scheme
    // header. In that case best-effort set from X-Forwarded-Proto.
    absl::string_view xfp = headers.getForwardedProtoValue();
    if (Http::HeaderUtility::schemeIsValid(xfp)) {
      headers.setScheme(xfp);
      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;
    }
     
     
     
    absl::string_view xfp = headers.getForwardedProtoValue();
    if (Http::HeaderUtility::schemeIsValid(xfp)) {
      headers.setScheme(xfp);
      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);
  }
}