global: fixes

This commit is contained in:
nym21
2026-03-23 14:17:07 +01:00
parent d6def7643d
commit c53c6560fa
11 changed files with 38 additions and 39 deletions
+4 -3
View File
@@ -14,7 +14,8 @@ pub enum ContentEncoding {
impl ContentEncoding {
/// Negotiate the best encoding from the Accept-Encoding header.
/// Priority: br > zstd > gzip > identity.
/// Priority: zstd > br > gzip > identity.
/// zstd is preferred over brotli: ~3-5x faster compression at comparable ratios.
pub fn negotiate(headers: &HeaderMap) -> Self {
let accept = match headers.get(header::ACCEPT_ENCODING) {
Some(v) => v,
@@ -29,8 +30,8 @@ impl ContentEncoding {
for part in s.split(',') {
let name = part.split(';').next().unwrap_or("").trim();
match name {
"br" => return Self::Brotli,
"zstd" => best = Self::Zstd,
"zstd" => return Self::Zstd,
"br" => best = Self::Brotli,
"gzip" if matches!(best, Self::Identity) => best = Self::Gzip,
_ => {}
}