bool BrotliDecompressorImpl::process(Common::BrotliContext& ctx, Buffer::Instance& output_buffer) {
  BrotliDecoderResult result;
  result = BrotliDecoderDecompressStream(state_.get(), &ctx.avail_in_, &ctx.next_in_,
                                         &ctx.avail_out_, &ctx.next_out_, nullptr);
  if (result == BROTLI_DECODER_RESULT_ERROR) {
    // TODO(rojkov): currently the Brotli library doesn't specify possible errors in its API. Add
    // more detailed stats when they are documented.
    stats_.brotli_error_.inc();
    return false;
  }

  if (Runtime::runtimeFeatureEnabled(
          "envoy.reloadable_features.enable_compression_bomb_protection") &&
      (output_buffer.length() > ctx.max_output_size_)) {
    stats_.brotli_error_.inc();
    return false;
  }

  ctx.updateOutput(output_buffer);

  return true;
}
bool BrotliDecompressorImpl::process(Common::BrotliContext& ctx, Buffer::Instance& output_buffer) {
  BrotliDecoderResult result;
  result = BrotliDecoderDecompressStream(state_.get(), &ctx.avail_in_, &ctx.next_in_,
                                         &ctx.avail_out_, &ctx.next_out_, nullptr);
  if (result == BROTLI_DECODER_RESULT_ERROR) {
     
     
    stats_.brotli_error_.inc();
    return false;
  }

  if (Runtime::runtimeFeatureEnabled(
          "envoy.reloadable_features.enable_compression_bomb_protection") &&
      (output_buffer.length() > ctx.max_output_size_)) {
    stats_.brotli_error_.inc();
    return false;
  }

  ctx.updateOutput(output_buffer);

  return true;
}