TEST_F(HttpConnectionManagerImplTest, RequestHeaderTimeoutCallbackDisarmsAndReturns408) {
  request_headers_timeout_ = std::chrono::milliseconds(10);
  setup(false, "");

  Event::MockTimer* request_header_timer;
  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> Http::Status {
    request_header_timer = setUpTimer();
    EXPECT_CALL(*request_header_timer, enableTimer(request_headers_timeout_, _));

    conn_manager_->newStream(response_encoder_);
    EXPECT_CALL(filter_callbacks_.connection_.dispatcher_, pushTrackedObject(_));
    EXPECT_CALL(filter_callbacks_.connection_.dispatcher_, popTrackedObject(_));
    return Http::okStatus();
  }));

  Buffer::OwnedImpl fake_input("GET /resource HTTP/1.1\r\n\r\n");
  conn_manager_->onData(fake_input, false); // kick off request

  // The client took too long to send headers.
  EXPECT_CALL(*request_header_timer, disableTimer);
  request_header_timer->invokeCallback();

  EXPECT_EQ(1U, stats_.named_.downstream_rq_header_timeout_.value());
}
TEST_F(HttpConnectionManagerImplTest, RequestHeaderTimeoutCallbackDisarmsAndReturns408) {
  request_headers_timeout_ = std::chrono::milliseconds(10);
  setup(false, "");

  Event::MockTimer* request_header_timer;
  EXPECT_CALL(*codec_, dispatch(_)).WillOnce(Invoke([&](Buffer::Instance&) -> Http::Status {
    request_header_timer = setUpTimer();
    EXPECT_CALL(*request_header_timer, enableTimer(request_headers_timeout_, _));

    conn_manager_->newStream(response_encoder_);
    EXPECT_CALL(filter_callbacks_.connection_.dispatcher_, pushTrackedObject(_));
    EXPECT_CALL(filter_callbacks_.connection_.dispatcher_, popTrackedObject(_));
    return Http::okStatus();
  }));

  Buffer::OwnedImpl fake_input("GET /resource HTTP/1.1\r\n\r\n");
  conn_manager_->onData(fake_input, false);  

   
  EXPECT_CALL(*request_header_timer, disableTimer);
  request_header_timer->invokeCallback();

  EXPECT_EQ(1U, stats_.named_.downstream_rq_header_timeout_.value());
}