  FuzzStream(ConnectionManagerImpl& conn_manager, FuzzConfig& config,
             const HeaderMap& request_headers,
             test::common::http::HeaderStatus decode_header_status, bool end_stream)
      : conn_manager_(conn_manager), config_(config) {
    config_.newStream();
    request_state_ = end_stream ? StreamState::Closed : StreamState::PendingDataOrTrailers;
    response_state_ = StreamState::PendingHeaders;
    decoder_filter_ = config.decoder_filter_;
    encoder_filter_ = config.encoder_filter_;
    EXPECT_CALL(*config_.codec_, dispatch(_))
        .WillOnce(InvokeWithoutArgs([this, &request_headers, end_stream] {
          decoder_ = &conn_manager_.newStream(encoder_);
          auto headers = std::make_unique<TestRequestHeaderMapImpl>(request_headers);
          if (headers->Method() == nullptr) {
            headers->setReferenceKey(Headers::get().Method, "GET");
          }
          if (headers->Host() != nullptr &&
              !HeaderUtility::authorityIsValid(headers->getHostValue())) {
            // Sanitize host header so we don't fail at ASSERTs that verify header sanity checks
            // which should have been performed by the codec.
            headers->setHost(Fuzz::replaceInvalidHostCharacters(headers->getHostValue()));
          }
          // If sendLocalReply is called:
          ON_CALL(encoder_, encodeHeaders(_, true))
              .WillByDefault(Invoke([this](const ResponseHeaderMap&, bool end_stream) -> void {
                response_state_ =
                    end_stream ? StreamState::Closed : StreamState::PendingDataOrTrailers;
              }));
          decoder_->decodeHeaders(std::move(headers), end_stream);
          return Http::okStatus();
        }));
    ON_CALL(*decoder_filter_, decodeHeaders(_, _))
        .WillByDefault(
            InvokeWithoutArgs([this, decode_header_status]() -> Http::FilterHeadersStatus {
              header_status_ = fromHeaderStatus(decode_header_status);
              return *header_status_;
            }));
    fakeOnData();
    FUZZ_ASSERT(testing::Mock::VerifyAndClearExpectations(config_.codec_));
  }
  FuzzStream(ConnectionManagerImpl& conn_manager, FuzzConfig& config,
             const HeaderMap& request_headers,
             test::common::http::HeaderStatus decode_header_status, bool end_stream)
      : conn_manager_(conn_manager), config_(config) {
    config_.newStream();
    request_state_ = end_stream ? StreamState::Closed : StreamState::PendingDataOrTrailers;
    response_state_ = StreamState::PendingHeaders;
    decoder_filter_ = config.decoder_filter_;
    encoder_filter_ = config.encoder_filter_;
    EXPECT_CALL(*config_.codec_, dispatch(_))
        .WillOnce(InvokeWithoutArgs([this, &request_headers, end_stream] {
          decoder_ = &conn_manager_.newStream(encoder_);
          auto headers = std::make_unique<TestRequestHeaderMapImpl>(request_headers);
          if (headers->Method() == nullptr) {
            headers->setReferenceKey(Headers::get().Method, "GET");
          }
          if (headers->Host() != nullptr &&
              !HeaderUtility::authorityIsValid(headers->getHostValue())) {
             
             
            headers->setHost(Fuzz::replaceInvalidHostCharacters(headers->getHostValue()));
          }
           
          ON_CALL(encoder_, encodeHeaders(_, true))
              .WillByDefault(Invoke([this](const ResponseHeaderMap&, bool end_stream) -> void {
                response_state_ =
                    end_stream ? StreamState::Closed : StreamState::PendingDataOrTrailers;
              }));
          decoder_->decodeHeaders(std::move(headers), end_stream);
          return Http::okStatus();
        }));
    ON_CALL(*decoder_filter_, decodeHeaders(_, _))
        .WillByDefault(
            InvokeWithoutArgs([this, decode_header_status]() -> Http::FilterHeadersStatus {
              header_status_ = fromHeaderStatus(decode_header_status);
              return *header_status_;
            }));
    fakeOnData();
    FUZZ_ASSERT(testing::Mock::VerifyAndClearExpectations(config_.codec_));
  }