  void newStream() {
    if (!codec_) {
      codec_ = new NiceMock<MockServerConnection>();
    }
    decoder_filter_ = new NiceMock<MockStreamDecoderFilter>();
    encoder_filter_ = new NiceMock<MockStreamEncoderFilter>();
    EXPECT_CALL(filter_factory_, createFilterChain(_))
        .WillOnce(Invoke([this](FilterChainFactoryCallbacks& callbacks) -> void {
          callbacks.addStreamDecoderFilter(StreamDecoderFilterSharedPtr{decoder_filter_});
          callbacks.addStreamEncoderFilter(StreamEncoderFilterSharedPtr{encoder_filter_});
        }));
    EXPECT_CALL(*decoder_filter_, setDecoderFilterCallbacks(_))
        .WillOnce(Invoke([this](StreamDecoderFilterCallbacks& callbacks) -> void {
          decoder_filter_->callbacks_ = &callbacks;
          callbacks.streamInfo().setResponseCodeDetails("");
        }));
    EXPECT_CALL(*encoder_filter_, setEncoderFilterCallbacks(_));
    EXPECT_CALL(filter_factory_, createUpgradeFilterChain("WebSocket", _, _))
        .WillRepeatedly(Invoke([&](absl::string_view, const Http::FilterChainFactory::UpgradeMap*,
                                   FilterChainFactoryCallbacks& callbacks) -> bool {
          filter_factory_.createFilterChain(callbacks);
          return true;
        }));
  }
  void newStream() {
    if (!codec_) {
      codec_ = new NiceMock<MockServerConnection>();
    }
    decoder_filter_ = new NiceMock<MockStreamDecoderFilter>();
    encoder_filter_ = new NiceMock<MockStreamEncoderFilter>();
    EXPECT_CALL(filter_factory_, createFilterChain(_))
        .WillOnce(Invoke([this](FilterChainFactoryCallbacks& callbacks) -> void {
          callbacks.addStreamDecoderFilter(StreamDecoderFilterSharedPtr{decoder_filter_});
          callbacks.addStreamEncoderFilter(StreamEncoderFilterSharedPtr{encoder_filter_});
        }));
    EXPECT_CALL(*decoder_filter_, setDecoderFilterCallbacks(_))
        .WillOnce(Invoke([this](StreamDecoderFilterCallbacks& callbacks) -> void {
          decoder_filter_->callbacks_ = &callbacks;
          callbacks.streamInfo().setResponseCodeDetails("");
        }));
    EXPECT_CALL(*encoder_filter_, setEncoderFilterCallbacks(_));
    EXPECT_CALL(filter_factory_, createUpgradeFilterChain("WebSocket", _, _))
        .WillRepeatedly(Invoke([&](absl::string_view, const Http::FilterChainFactory::UpgradeMap*,
                                   FilterChainFactoryCallbacks& callbacks) -> bool {
          filter_factory_.createFilterChain(callbacks);
          return true;
        }));
  }