TEST_P(ProtocolIntegrationTest, OverflowingResponseCode) {
  useAccessLog("%RESPONSE_CODE_DETAILS%");
  initialize();

  codec_client_ = makeHttpConnection(lookupPort("http"));
  auto response = codec_client_->makeHeaderOnlyRequest(default_request_headers_);
  if (upstreamProtocol() == FakeHttpConnection::Type::HTTP1) {
    // The http1 codec won't send illegal status codes so send raw HTTP/1.1
    FakeRawConnectionPtr fake_upstream_connection;
    ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(fake_upstream_connection));
    ASSERT(fake_upstream_connection != nullptr);
    ASSERT_TRUE(fake_upstream_connection->write(
        "HTTP/1.1 11111111111111111111111111111111111111111111111111111111111111111 OK\r\n",
        false));
    ASSERT_TRUE(fake_upstream_connection->waitForDisconnect());
  } else {
    waitForNextUpstreamRequest();
    default_response_headers_.setStatus(
        "11111111111111111111111111111111111111111111111111111111111111111");
    upstream_request_->encodeHeaders(default_response_headers_, false);
    ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect());
  }

  ASSERT_TRUE(response->waitForEndStream());
  EXPECT_EQ("502", response->headers().getStatusValue());
  EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("protocol_error"));
}
TEST_P(ProtocolIntegrationTest, OverflowingResponseCode) {
  useAccessLog("%RESPONSE_CODE_DETAILS%");
  initialize();

  codec_client_ = makeHttpConnection(lookupPort("http"));
  auto response = codec_client_->makeHeaderOnlyRequest(default_request_headers_);
  if (upstreamProtocol() == FakeHttpConnection::Type::HTTP1) {
     
    FakeRawConnectionPtr fake_upstream_connection;
    ASSERT_TRUE(fake_upstreams_[0]->waitForRawConnection(fake_upstream_connection));
    ASSERT(fake_upstream_connection != nullptr);
    ASSERT_TRUE(fake_upstream_connection->write(
        "HTTP/1.1 11111111111111111111111111111111111111111111111111111111111111111 OK\r\n",
        false));
    ASSERT_TRUE(fake_upstream_connection->waitForDisconnect());
  } else {
    waitForNextUpstreamRequest();
    default_response_headers_.setStatus(
        "11111111111111111111111111111111111111111111111111111111111111111");
    upstream_request_->encodeHeaders(default_response_headers_, false);
    ASSERT_TRUE(fake_upstream_connection_->waitForDisconnect());
  }

  ASSERT_TRUE(response->waitForEndStream());
  EXPECT_EQ("502", response->headers().getStatusValue());
  EXPECT_THAT(waitForAccessLog(access_log_name_), HasSubstr("protocol_error"));
}