{"record":{"id":"ffb64dcaf5734437","repo":"BigPizzaV3/CodexPlusPlus","slug":"content-encoding-encoding","errorCode":null,"errorMessage":"不支持的 Content-Encoding：{encoding}","messagePattern":"不支持的 Content-Encoding：(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"warning","filePath":"crates/codex-plus-core/src/launcher.rs","lineNumber":1449,"sourceCode":"\nfn decode_protocol_proxy_request_body(\n    body: &[u8],\n    content_encoding: Option<&str>,\n) -> anyhow::Result<String> {\n    let encoding = content_encoding.unwrap_or_default().trim();\n    let decoded = if encoding.is_empty() || encoding.eq_ignore_ascii_case(\"identity\") {\n        body.to_vec()\n    } else if encoding.eq_ignore_ascii_case(\"zstd\") {\n        let decoder = zstd::stream::read::Decoder::new(std::io::Cursor::new(body))?;\n        let mut limited = decoder.take((MAX_HTTP_BODY_BYTES + 1) as u64);\n        let mut decoded = Vec::new();\n        limited.read_to_end(&mut decoded)?;\n        if decoded.len() > MAX_HTTP_BODY_BYTES {\n            anyhow::bail!(\"解压后的请求体超过大小限制\");\n        }\n        decoded\n    } else {\n        anyhow::bail!(\"不支持的 Content-Encoding：{encoding}\");\n    };\n\n    String::from_utf8(decoded)\n        .map_err(|error| anyhow::anyhow!(\"Responses 请求体不是 UTF-8：{error}\"))\n}\n\nfn overlay_image_response() -> (String, Vec<u8>, String, &'static str) {\n    let not_found = || {\n        (\n            \"404 Not Found\".to_string(),\n            serde_json::to_vec(&serde_json::json!({\n                \"status\": \"failed\",\n                \"message\": \"图片覆盖层未启用或图片不可用\"\n            }))\n            .unwrap_or_default(),\n            \"application/json; charset=utf-8\".to_string(),\n            \"helper.overlay_image_not_found\",\n        )","sourceCodeStart":1431,"sourceCodeEnd":1467,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/launcher.rs#L1431-L1467","documentation":"The request-body decoder only supports a fixed set of Content-Encoding values (gzip, deflate/zstd, identity). If the client sends any other encoding (brotli, compress, unknown tokens), the decoder cannot proceed safely and bails with this message naming the offending encoding value.","triggerScenarios":"An HTTP request with a `Content-Encoding` header value not in the supported set, e.g. `br` (brotli), `compress`, or a malformed/typo'd encoding string.","commonSituations":"Clients with aggressive compression defaults (brotli); corporate proxies adding encodings; version drift where a newer client uses an encoding the launcher does not yet decode.","solutions":["Remove or change the Content-Encoding header to one of the supported values (gzip/zstd/identity) on the client side","Send the request body uncompressed (identity)","Add a decoder branch for the desired encoding (e.g. brotli) in the launcher if support is needed"],"exampleFix":"// before\nreq.headers.set(\"Content-Encoding\", \"br\");\n// after\nreq.headers.set(\"Content-Encoding\", \"gzip\"); // or remove the header","handlingStrategy":"validation","validationCode":"const SUPPORTED = [\"gzip\", \"zstd\", \"identity\"];\nif (encoding && !SUPPORTED.includes(encoding.toLowerCase())) {\n  throw new Error(`unsupported Content-Encoding: ${encoding}`);\n}","typeGuard":"fn is_supported_encoding(e: &str) -> bool {\n    [\"gzip\", \"zstd\", \"identity\"].iter().any(|s| e.eq_ignore_ascii_case(s))\n}","tryCatchPattern":"match encoding {\n    Some(e) if !is_supported_encoding(&e) => respond(415, format!(\"unsupported encoding {e}\")),\n    _ => forward(request).await,\n}","preventionTips":["Restrict client Accept-Encoding/Content-Encoding to supported values","Test against the launcher with each encoding you plan to send","Prefer identity for maximum compatibility","Keep client and launcher encoding support lists in sync"],"tags":["rust","http","content-encoding","compression","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}