62 bool only_available =
true);
routing::Middleware compress(CompressOptions options={})
Returns a middleware that compresses response bodies with brotli, zstd or gzip, whichever the client ...
Definition HttpRequest.hpp:19
bool accepts_gzip(std::string_view accept_encoding)
Whether an Accept-Encoding header value allows gzip.
bool compress_body(ContentCoding coding, const std::string &in, std::string &out, const CompressOptions &options={})
Compresses in with coding at the levels in options.
bool coding_available(ContentCoding coding)
True if this build can produce coding.
ContentCoding negotiate_coding(std::string_view accept_encoding, const std::vector< ContentCoding > &preference, bool only_available=true)
Chooses the coding for a response.
ContentCoding
A response content coding (RFC 9110 section 8.4.1).
Definition Compress.hpp:15
@ Zstd
"zstd" (needs ORBIT_ENABLE_ZSTD, RFC 8878).
@ Gzip
"gzip" (zlib, always available).
@ Brotli
"br" (needs ORBIT_ENABLE_BROTLI).
@ Identity
No compression.
std::string_view coding_name(ContentCoding coding)
The Content-Encoding token for coding ("gzip", "br", "zstd"; "" for identity).
std::function< bool(http::HttpRequest &, std::shared_ptr< http::ResponseWriter >)> Middleware
Definition Router.hpp:19
Options for compress().
Definition Compress.hpp:23
size_t min_size
Bodies smaller than this are sent as they are.
Definition Compress.hpp:27
int zstd_level
1 to 19
Definition Compress.hpp:30
std::vector< ContentCoding > preference
Codings offered, best first. Codings this build lacks are skipped.
Definition Compress.hpp:25
int gzip_level
1 (fast) to 9 (small)
Definition Compress.hpp:28
int brotli_quality
0 to 11; 4 to 6 suits responses made per request
Definition Compress.hpp:29