HTTP Compression
RustMailer supports built-in HTTP compression and decompression using the Poem web framework. This helps reduce bandwidth usage and improve API performance, especially for large JSON payloads or webhook traffic.
✅ Overview
RustMailer automatically selects compression and decompression algorithms based on HTTP headers:
- Request Decompression: If the request contains a
Content-Encodingheader, RustMailer will decompress it accordingly. - Response Compression: If the request includes an
Accept-Encodingheader, RustMailer will choose the best supported compression algorithm.
🛠️ How to Enable
You can enable HTTP compression via command-line argument or environment variable:
| Command-line Argument | Environment Variable | Default | Description |
|---|---|---|---|
--rustmailer-http-compression-enabled | RUSTMAILER_HTTP_COMPRESSION_ENABLED | false | Enables HTTP compression and decoding |
Example: Enable via Command Line
./rustmailer --rustmailer-http-compression-enabled
Example: Enable via Environment Variable
export RUSTMAILER_HTTP_COMPRESSION_ENABLED=true
./rustmailer
🔄 Supported Compression Algorithms
RustMailer supports the following compression types:
gzipdeflatebr(Brotli)zstd*(wildcard - auto-select best available)
Sample Headers
Accept-Encoding: br, gzip, deflate
Content-Encoding: gzip
💡 Use Cases
- High-throughput webhook traffic
- Mobile or bandwidth-constrained environments
- Large JSON API responses
- Uploading IMAP sync data efficiently