void ZlibDecompressorImpl::decompress(const Buffer::Instance& input_buffer,
                                      Buffer::Instance& output_buffer) {
  uint64_t limit = MaxInflateRatio * input_buffer.length();

  for (const Buffer::RawSlice& input_slice : input_buffer.getRawSlices()) {
    zstream_ptr_->avail_in = input_slice.len_;
    zstream_ptr_->next_in = static_cast<Bytef*>(input_slice.mem_);
    while (inflateNext()) {
      if (zstream_ptr_->avail_out == 0) {
        updateOutput(output_buffer);
      }

      if (Runtime::runtimeFeatureEnabled(
              "envoy.reloadable_features.enable_compression_bomb_protection") &&
          (output_buffer.length() > limit)) {
        stats_.zlib_data_error_.inc();
        ENVOY_LOG(trace,
                  "excessive decompression ratio detected: output "
                  "size {} for input size {}",
                  output_buffer.length(), input_buffer.length());
        return;
      }
    }
  }

  // Flush z_stream and reset its buffer. Otherwise the stale content of the buffer
  // will pollute output upon the next call to decompress().
  updateOutput(output_buffer);
}
void ZlibDecompressorImpl::decompress(const Buffer::Instance& input_buffer,
                                      Buffer::Instance& output_buffer) {
  uint64_t limit = MaxInflateRatio * input_buffer.length();

  for (const Buffer::RawSlice& input_slice : input_buffer.getRawSlices()) {
    zstream_ptr_->avail_in = input_slice.len_;
    zstream_ptr_->next_in = static_cast<Bytef*>(input_slice.mem_);
    while (inflateNext()) {
      if (zstream_ptr_->avail_out == 0) {
        updateOutput(output_buffer);
      }

      if (Runtime::runtimeFeatureEnabled(
              "envoy.reloadable_features.enable_compression_bomb_protection") &&
          (output_buffer.length() > limit)) {
        stats_.zlib_data_error_.inc();
        ENVOY_LOG(trace,
                  "excessive decompression ratio detected: output "
                  "size {} for input size {}",
                  output_buffer.length(), input_buffer.length());
        return;
      }
    }
  }

   
   
  updateOutput(output_buffer);
}