TEST_P(DownstreamProtocolIntegrationTest, FaultyFilterWithConnect) {
  if (upstreamProtocol() == Http::CodecType::HTTP3) {
    // For QUIC, even through the headers are not sent upstream, the stream will
    // be created. Use the autonomous upstream and allow incomplete streams.
    autonomous_allow_incomplete_streams_ = true;
    autonomous_upstream_ = true;
  }
  // Faulty filter that removed host in a CONNECT request.
  config_helper_.addConfigModifier(
      [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
              hcm) -> void {
        ConfigHelper::setConnectConfig(hcm, false, false,
                                       downstreamProtocol() == Http::CodecType::HTTP3);
      });
  useAccessLog("%RESPONSE_CODE_DETAILS%");
  config_helper_.prependFilter("{ name: invalid-header-filter, typed_config: { \"@type\": "
                               "type.googleapis.com/google.protobuf.Empty } }");
  initialize();
  codec_client_ = makeHttpConnection(lookupPort("http"));

  // Missing host for CONNECT
  auto headers = Http::TestRequestHeaderMapImpl{
      {":method", "CONNECT"}, {":scheme", "http"}, {":authority", "www.host.com:80"}};

  auto response = std::move((codec_client_->startRequest(headers)).second);

  ASSERT_TRUE(response->waitForEndStream());
  EXPECT_TRUE(response->complete());
  EXPECT_EQ("503", response->headers().getStatusValue());
  EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("missing_required_header"));
}
TEST_P(DownstreamProtocolIntegrationTest, FaultyFilterWithConnect) {
  if (upstreamProtocol() == Http::CodecType::HTTP3) {
     
     
    autonomous_allow_incomplete_streams_ = true;
    autonomous_upstream_ = true;
  }
   
  config_helper_.addConfigModifier(
      [&](envoy::extensions::filters::network::http_connection_manager::v3::HttpConnectionManager&
              hcm) -> void {
        ConfigHelper::setConnectConfig(hcm, false, false,
                                       downstreamProtocol() == Http::CodecType::HTTP3);
      });
  useAccessLog("%RESPONSE_CODE_DETAILS%");
  config_helper_.prependFilter("{ name: invalid-header-filter, typed_config: { \"@type\": "
                               "type.googleapis.com/google.protobuf.Empty } }");
  initialize();
  codec_client_ = makeHttpConnection(lookupPort("http"));

   
  auto headers = Http::TestRequestHeaderMapImpl{
      {":method", "CONNECT"}, {":scheme", "http"}, {":authority", "www.host.com:80"}};

  auto response = std::move((codec_client_->startRequest(headers)).second);

  ASSERT_TRUE(response->waitForEndStream());
  EXPECT_TRUE(response->complete());
  EXPECT_EQ("503", response->headers().getStatusValue());
  EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("missing_required_header"));
}