TEST_P(DownstreamProtocolIntegrationTest, RouterRedirectHttpRequest) {
  autonomous_upstream_ = true;
  useAccessLog("%DOWNSTREAM_WIRE_BYTES_SENT% %DOWNSTREAM_WIRE_BYTES_RECEIVED% "
               "%DOWNSTREAM_HEADER_BYTES_SENT% %DOWNSTREAM_HEADER_BYTES_RECEIVED%");
  auto host = config_helper_.createVirtualHost("www.redirect.com", "/");
  host.set_require_tls(envoy::config::route::v3::VirtualHost::ALL);
  config_helper_.addVirtualHost(host);
  initialize();

  BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest(
      lookupPort("http"), "GET", "/foo", "", downstream_protocol_, version_, "www.redirect.com");
  ASSERT_TRUE(response->complete());
  if (downstream_protocol_ <= Http::CodecType::HTTP2) {
    EXPECT_EQ("301", response->headers().getStatusValue());
    EXPECT_EQ("https://www.redirect.com/foo",
              response->headers().get(Http::Headers::get().Location)[0]->value().getStringView());
    expectDownstreamBytesSentAndReceived(BytesCountExpectation(145, 45, 111, 23),
                                         BytesCountExpectation(0, 30, 0, 30),
                                         BytesCountExpectation(0, 30, 0, 30));
  } else {
    // All QUIC requests use https, and should not be redirected. (Even those sent with http scheme
    // will be overridden to https by HCM.)
    EXPECT_EQ("200", response->headers().getStatusValue());
  }
}
TEST_P(DownstreamProtocolIntegrationTest, RouterRedirectHttpRequest) {
  autonomous_upstream_ = true;
  useAccessLog("%DOWNSTREAM_WIRE_BYTES_SENT% %DOWNSTREAM_WIRE_BYTES_RECEIVED% "
               "%DOWNSTREAM_HEADER_BYTES_SENT% %DOWNSTREAM_HEADER_BYTES_RECEIVED%");
  auto host = config_helper_.createVirtualHost("www.redirect.com", "/");
  host.set_require_tls(envoy::config::route::v3::VirtualHost::ALL);
  config_helper_.addVirtualHost(host);
  initialize();

  BufferingStreamDecoderPtr response = IntegrationUtil::makeSingleRequest(
      lookupPort("http"), "GET", "/foo", "", downstream_protocol_, version_, "www.redirect.com");
  ASSERT_TRUE(response->complete());
  if (downstream_protocol_ <= Http::CodecType::HTTP2) {
    EXPECT_EQ("301", response->headers().getStatusValue());
    EXPECT_EQ("https://www.redirect.com/foo",
              response->headers().get(Http::Headers::get().Location)[0]->value().getStringView());
    expectDownstreamBytesSentAndReceived(BytesCountExpectation(145, 45, 111, 23),
                                         BytesCountExpectation(0, 30, 0, 30),
                                         BytesCountExpectation(0, 30, 0, 30));
  } else {
     
     
    EXPECT_EQ("200", response->headers().getStatusValue());
  }
}