Skip to main content

hyperlane_plugin_compression/
const.rs

1/// Default minimum response body size eligible for compression (`1024` bytes).
2pub const DEFAULT_MIN_COMPRESS_BYTES: usize = 1024;
3
4/// Default maximum decompressed inbound request payload size (`16 MiB`).
5pub const DEFAULT_MAX_DECOMPRESSED_BYTES: usize = 16 * 1024 * 1024;
6
7/// Default decompression buffer chunk size (`8 KiB`).
8pub const DEFAULT_DECODE_BUFFER_SIZE: usize = 8192;
9
10/// Default `Content-Type` for compression rejection wire responses.
11pub const DEFAULT_ERROR_CONTENT_TYPE: &str = "application/json; charset=utf-8";
12
13/// Default JSON body emitted when an inbound request uses an unsupported `Content-Encoding`.
14pub const DEFAULT_UNSUPPORTED_ENCODING_BODY: &[u8] =
15    br#"{"error":"unsupported_media_type","message":"unsupported content-encoding"}"#;
16
17/// Default JSON body emitted when a decompressed request exceeds the configured limit.
18pub const DEFAULT_DECOMPRESS_LIMIT_BODY: &[u8] =
19    br#"{"error":"payload_too_large","message":"decompressed request body exceeds limit"}"#;
20
21/// MIME prefixes skipped by default because payloads are already compressed or streamed.
22pub(crate) const DEFAULT_SKIP_MIME_PREFIXES: &[&str] = &[
23    "image/",
24    "video/",
25    "audio/",
26    "font/",
27    "application/zip",
28    "application/gzip",
29    "application/x-gzip",
30    "application/zstd",
31    "application/octet-stream",
32    "text/event-stream",
33];
34
35/// Cache-Control directive disallowing intermediaries from applying content codings.
36pub(crate) const CACHE_CONTROL_NO_TRANSFORM: &str = "no-transform";
37
38/// Identity content-encoding token.
39pub(crate) const CONTENT_ENCODING_IDENTITY: &str = "identity";
40
41/// Lowercase ASCII `gzip` token bytes for zero-allocation fallback negotiation.
42pub(crate) const GZIP_TOKEN_BYTES: &[u8] = b"gzip";
43
44/// Lowercase ASCII `deflate` token bytes for zero-allocation fallback negotiation.
45pub(crate) const DEFLATE_TOKEN_BYTES: &[u8] = b"deflate";
46
47/// Wildcard `Vary` header value.
48pub(crate) const VARY_WILDCARD: &str = "*";