{"record":{"id":"cb14a4443a6bc519","repo":"BigPizzaV3/CodexPlusPlus","slug":"dreamskin-content-type","errorCode":null,"errorMessage":"DreamSkin 服务返回了不支持的内容类型：{content_type}","messagePattern":"DreamSkin 服务返回了不支持的内容类型：(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":455,"sourceCode":") -> anyhow::Result<Vec<u8>> {\n    let response = client\n        .get(url)\n        .header(reqwest::header::ACCEPT, expected_content_type)\n        .send()\n        .await\n        .with_context(|| format!(\"请求失败：{url}\"))?;\n    if !response.status().is_success() {\n        bail!(\"DreamSkin 服务返回 HTTP {}\", response.status());\n    }\n    let content_type = response\n        .headers()\n        .get(reqwest::header::CONTENT_TYPE)\n        .and_then(|value| value.to_str().ok())\n        .and_then(|value| value.split(';').next())\n        .map(str::trim)\n        .unwrap_or_default();\n    if content_type != expected_content_type {\n        bail!(\"DreamSkin 服务返回了不支持的内容类型：{content_type}\");\n    }\n    if response\n        .content_length()\n        .is_some_and(|length| length == 0 || length > limit as u64)\n    {\n        bail!(\"DreamSkin 响应超过大小限制\");\n    }\n    let mut bytes = Vec::new();\n    let mut stream = response.bytes_stream();\n    while let Some(chunk) = stream.next().await {\n        let chunk = chunk?;\n        if bytes.len().saturating_add(chunk.len()) > limit {\n            bail!(\"DreamSkin 响应超过大小限制\");\n        }\n        bytes.extend_from_slice(&chunk);\n    }\n    if bytes.is_empty() {\n        bail!(\"DreamSkin 服务返回空响应\");","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L437-L473","documentation":"download_limited validates the response's Content-Type header (ignoring parameters like charset) against the expected type for the request (catalog JSON vs. package ZIP). A mismatch — including a missing/empty Content-Type — is rejected to avoid parsing a wrong or hostile body.","triggerScenarios":"fetch_community_catalog or install_community_theme receiving a response whose base content type is not exactly the expected value, e.g. text/html from an error/interstitial page, application/octet-stream instead of application/zip, or a missing header yielding an empty string in the message.","commonSituations":"Captive portal or proxy returning an HTML login page; CDN misconfiguration serving the wrong MIME type; server upgrade changing content types; request sent to the wrong endpoint.","solutions":["Check the returned content type in the message and verify you are calling the correct endpoint (catalog URL vs. package URL).","Inspect for a proxy/captive portal injecting HTML responses and fix network routing.","Fix the server/CDN MIME configuration so it serves application/json or application/zip as expected.","Retry later if it is a transient server-side misconfiguration; report to the service operator."],"exampleFix":"// before\nlet url = format!(\"{base}/themes/{id}/download\"); // wrong endpoint, returns JSON not zip\n// after\nlet url = format!(\"{base}/community/packages/{version_id}.zip\");","handlingStrategy":"validation","validationCode":"// Rust\nlet ct = resp.headers().get(reqwest::header::CONTENT_TYPE)\n    .and_then(|v| v.to_str().ok())\n    .and_then(|v| v.split(';').next())\n    .map(str::trim)\n    .unwrap_or_default();\nlet acceptable = ct == expected_content_type;","typeGuard":null,"tryCatchPattern":"// Rust\nErr(e) if e.to_string().contains(\"内容类型\") => {\n    eprintln!(\"服务返回了非预期内容（可能被代理拦截），请检查网络后重试\");\n}","preventionTips":["Bypass or properly configure proxies/captive portals","Verify endpoint URLs map to the right resource types","Check server MIME configuration after deployments","Detect HTML responses early (proxy interference) and surface a network-diagnostic message"],"tags":["network","http","content-type"],"backgroundTag":"unexpected-response-shape","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"}