{"record":{"id":"48cdb89c457fab12","repo":"ducaale/xh","slug":"unknown-compression-type","errorCode":null,"errorMessage":"unknown compression type","messagePattern":"unknown compression type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/decoder.rs","lineNumber":33,"sourceCode":"    Gzip,\n    Deflate,\n    Brotli,\n    Zstd,\n}\n\nimpl FromStr for CompressionType {\n    type Err = anyhow::Error;\n    fn from_str(value: &str) -> anyhow::Result<CompressionType> {\n        match value {\n            // RFC 2616 section 3.5:\n            //   For compatibility with previous implementations of HTTP,\n            //   applications SHOULD consider \"x-gzip\" and \"x-compress\" to be\n            //   equivalent to \"gzip\" and \"compress\" respectively.\n            \"gzip\" | \"x-gzip\" => Ok(CompressionType::Gzip),\n            \"deflate\" => Ok(CompressionType::Deflate),\n            \"br\" => Ok(CompressionType::Brotli),\n            \"zstd\" => Ok(CompressionType::Zstd),\n            _ => Err(anyhow::anyhow!(\"unknown compression type\")),\n        }\n    }\n}\n\n// See https://github.com/seanmonstar/reqwest/blob/9bd4e90ec3401c2c5bc435c58954f3d52ab53e99/src/async_impl/decoder.rs#L150\npub fn get_compression_type(headers: &HeaderMap) -> Option<CompressionType> {\n    let mut compression_type = headers\n        .get_all(CONTENT_ENCODING)\n        .iter()\n        .find_map(|value| value.to_str().ok().and_then(|value| value.parse().ok()));\n\n    if compression_type.is_none() {\n        compression_type = headers\n            .get_all(TRANSFER_ENCODING)\n            .iter()\n            .find_map(|value| value.to_str().ok().and_then(|value| value.parse().ok()));\n    }\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/ducaale/xh/blob/2404aceecc08b0b2d100fedc96f57745cd5904dc/src/decoder.rs#L15-L51","documentation":"CompressionType::from_str maps a Content-Encoding token to the tool's supported decoders (gzip, deflate, brotli, zstd). Any other token — even a valid but unimplemented encoding like 'compress' or 'identity' — returns this bare error.","triggerScenarios":"Server responds with Content-Encoding: compress, x-compress, zstd when the binary was built without the zstd feature, or any custom/unrecognized token.","commonSituations":"Legacy servers using the historical 'compress' encoding, misconfigured servers advertising encodings they don't actually send, CDN injecting unusual Content-Encoding values, feature-flag differences between builds.","solutions":["Fix or disable the server/CDN header so it advertises a supported encoding (gzip, deflate, br, zstd)","Set Accept-Encoding on your request to only supported values so the server doesn't pick an unknown one","Check the decoder's build features (e.g. zstd may be optional) and rebuild with the needed feature"],"exampleFix":"// before (server sends Content-Encoding: compress)\ncurl -H 'Accept-Encoding: gzip, br' ...\n// after\nxh GET https://example.com Accept-Encoding:gzip, deflate, br","handlingStrategy":"validation","validationCode":"const SUPPORTED: &[&str] = &[\"gzip\", \"x-gzip\", \"deflate\", \"br\", \"zstd\"];\nfn is_supported_encoding(token: &str) -> bool {\n    SUPPORTED.contains(&token.trim().to_lowercase().as_str())\n}","typeGuard":null,"tryCatchPattern":"let ct = get_compression_type(&headers);\nlet decoder = match ct.map(CompressionType::from_str) {\n    Some(Err(e)) => { eprintln!(\"{e}: falling back to identity\"); None }\n    other => other.ok().flatten(),\n};","preventionTips":["Send Accept-Encoding limited to gzip, deflate, br, zstd","Fix server/CDN Content-Encoding configuration","Verify optional features (e.g. zstd) are compiled into the binary"],"tags":["http","compression","content-encoding","decoder","rust"],"backgroundTag":"unsupported-enum-value","analyzedSha":"2404aceecc08b0b2d100fedc96f57745cd5904dc","analyzedAt":"2026-09-13T19:13:33.814Z","contentChangedAt":"2026-09-13T19:13:33.814Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}