TEST_P(ProtocolIntegrationTest, AddEncodedTrailers) {
  config_helper_.prependFilter(R"EOF(
name: add-trailers-filter
typed_config:
  "@type": type.googleapis.com/google.protobuf.Empty
)EOF");
  initialize();

  codec_client_ = makeHttpConnection(lookupPort("http"));
  auto response = codec_client_->makeRequestWithBody(default_request_headers_, 128);
  waitForNextUpstreamRequest();
  upstream_request_->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "503"}}, false);
  upstream_request_->encodeData(128, true);
  ASSERT_TRUE(response->waitForEndStream());

  if (upstreamProtocol() >= Http::CodecType::HTTP2) {
    EXPECT_EQ("decode", upstream_request_->trailers()
                            ->get(Http::LowerCaseString("grpc-message"))[0]
                            ->value()
                            .getStringView());
  }
  EXPECT_TRUE(response->complete());
  EXPECT_EQ("503", response->headers().getStatusValue());
  if (downstream_protocol_ >= Http::CodecType::HTTP2) {
    EXPECT_EQ("encode", response->trailers()->getGrpcMessageValue());
  }
}
TEST_P(ProtocolIntegrationTest, AddEncodedTrailers) {
  config_helper_.prependFilter(R"EOF(
name: add-trailers-filter
typed_config:
  "@type": type.googleapis.com/google.protobuf.Empty
)EOF");
  initialize();

  codec_client_ = makeHttpConnection(lookupPort("http"));
  auto response = codec_client_->makeRequestWithBody(default_request_headers_, 128);
  waitForNextUpstreamRequest();
  upstream_request_->encodeHeaders(Http::TestResponseHeaderMapImpl{{":status", "503"}}, false);
  upstream_request_->encodeData(128, true);
  ASSERT_TRUE(response->waitForEndStream());

  if (upstreamProtocol() >= Http::CodecType::HTTP2) {
    EXPECT_EQ("decode", upstream_request_->trailers()
                            ->get(Http::LowerCaseString("grpc-message"))[0]
                            ->value()
                            .getStringView());
  }
  EXPECT_TRUE(response->complete());
  EXPECT_EQ("503", response->headers().getStatusValue());
  if (downstream_protocol_ >= Http::CodecType::HTTP2) {
    EXPECT_EQ("encode", response->trailers()->getGrpcMessageValue());
  }
}