Envoy::StatusOr<size_t> ConnectionImpl::dispatchSlice(const char* slice, size_t len) {
  ASSERT(codec_status_.ok() && dispatching_);
  auto [nread, rc] = parser_->execute(slice, len);
  if (!codec_status_.ok()) {
    return codec_status_;
  }

  if (rc != parser_->statusToInt(ParserStatus::Success) &&
      rc != parser_->statusToInt(ParserStatus::Paused)) {
    RETURN_IF_ERROR(sendProtocolError(Http1ResponseCodeDetails::get().HttpCodecError));
    // Avoid overwriting the codec_status_ set in the callbacks.
    ASSERT(codec_status_.ok());
    codec_status_ =
        codecProtocolError(absl::StrCat("http/1.1 protocol error: ", parser_->errnoName(rc)));
    return codec_status_;
  }

  return nread;
}
Envoy::StatusOr<size_t> ConnectionImpl::dispatchSlice(const char* slice, size_t len) {
  ASSERT(codec_status_.ok() && dispatching_);
  auto [nread, rc] = parser_->execute(slice, len);
  if (!codec_status_.ok()) {
    return codec_status_;
  }

  if (rc != parser_->statusToInt(ParserStatus::Success) &&
      rc != parser_->statusToInt(ParserStatus::Paused)) {
    RETURN_IF_ERROR(sendProtocolError(Http1ResponseCodeDetails::get().HttpCodecError));
     
    ASSERT(codec_status_.ok());
    codec_status_ =
        codecProtocolError(absl::StrCat("http/1.1 protocol error: ", parser_->errnoName(rc)));
    return codec_status_;
  }

  return nread;
}