Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Triton inference server Server DataCompressor

From Leeroopedia
Knowledge Sources
Domains HTTP, Data_Compression
Last Updated 2026-02-13 17:00 GMT

Overview

Concrete tool for compressing and decompressing HTTP request/response data using gzip and deflate algorithms via zlib.

Description

The DataCompressor class provides static methods for compressing and decompressing data that flows through Triton's HTTP endpoints. It operates directly on libevent evbuffer objects, supporting GZIP, DEFLATE, and IDENTITY (no-op) compression types. The implementation manages streaming compression with configurable maximum decompressed size limits to prevent memory exhaustion from malicious payloads.

Usage

Used internally by the HTTP server to compress responses and decompress incoming requests based on Content-Encoding and Accept-Encoding headers. Not directly imported by external users.

Code Reference

Source Location

Signature

class DataCompressor {
 public:
  enum Type { IDENTITY, DEFLATE, GZIP };

  static TRITONSERVER_Error* CompressData(
      Type type, evbuffer* source, evbuffer* compressed);

  static TRITONSERVER_Error* DecompressData(
      Type type, evbuffer* source, evbuffer* decompressed,
      size_t max_decompressed_size = 0);

  static Type GetType(const std::string& encoding);
  static const char* GetName(Type type);
};

Import

#include "data_compressor.h"

I/O Contract

Inputs

Name Type Required Description
type DataCompressor::Type Yes Compression algorithm (IDENTITY, DEFLATE, GZIP)
source evbuffer* Yes Input data buffer from libevent
max_decompressed_size size_t No Maximum allowed decompressed size (0 = unlimited)

Outputs

Name Type Description
compressed/decompressed evbuffer* Output buffer containing processed data
error TRITONSERVER_Error* nullptr on success, error object on failure

Usage Examples

Compressing HTTP Response

#include "data_compressor.h"

// Compress response data before sending
evbuffer* raw_response = evbuffer_new();
evbuffer* compressed_response = evbuffer_new();

// Add data to raw_response...

TRITONSERVER_Error* err = DataCompressor::CompressData(
    DataCompressor::GZIP, raw_response, compressed_response);
if (err == nullptr) {
  // Send compressed_response with Content-Encoding: gzip
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment