{
  "id": "nginx/upstream-sent-http-1-1-chunked-with-content-length",
  "signature": "upstream sent chunked transfer encoding while sending Content-Length header, client: 10.0.0.1, server: example.com",
  "signature_zh": "上游在发送 Content-Length 头的同时发送了分块传输编码，客户端：10.0.0.1，服务器：example.com",
  "regex": "upstream sent chunked transfer encoding while sending Content-Length header",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Upstream server sends conflicting HTTP headers: both Content-Length and Transfer-Encoding: chunked, violating HTTP/1.1 spec.",
  "root_cause_type": "generic",
  "root_cause_zh": "上游服务器发送了冲突的 HTTP 头：同时包含 Content-Length 和 Transfer-Encoding: chunked，违反了 HTTP/1.1 规范。",
  "versions": [
    {
      "version": "nginx 1.20.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.22.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.26.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Set proxy_http_version 1.0;",
      "why_fails": "HTTP/1.0 does not support chunked encoding, but the upstream may still send conflicting headers; this can cause other issues like connection close.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Disable chunked transfer with proxy_set_header Transfer-Encoding '';",
      "why_fails": "This removes the header from the request to upstream, not the response; the error is about the response from upstream.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase proxy_buffer_size",
      "why_fails": "Buffer size does not affect header parsing or protocol compliance; the error is a protocol violation, not a buffer overflow.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix the upstream application to not send both Content-Length and Transfer-Encoding headers. For example, in a Python Flask app, remove the Content-Length header when using chunked encoding:\n@app.after_request\ndef remove_conflicting_headers(response):\n    if response.headers.get('Transfer-Encoding') == 'chunked':\n        response.headers.pop('Content-Length', None)\n    return response",
      "success_rate": 0.85,
      "how": "Fix the upstream application to not send both Content-Length and Transfer-Encoding headers. For example, in a Python Flask app, remove the Content-Length header when using chunked encoding:\n@app.after_request\ndef remove_conflicting_headers(response):\n    if response.headers.get('Transfer-Encoding') == 'chunked':\n        response.headers.pop('Content-Length', None)\n    return response",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use nginx's proxy_hide_header directive to remove the conflicting Content-Length header from upstream responses:\nproxy_hide_header Content-Length;\nThis forces nginx to rely on chunked encoding alone.",
      "success_rate": 0.75,
      "how": "Use nginx's proxy_hide_header directive to remove the conflicting Content-Length header from upstream responses:\nproxy_hide_header Content-Length;\nThis forces nginx to rely on chunked encoding alone.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Fix the upstream application to not send both Content-Length and Transfer-Encoding headers. For example, in a Python Flask app, remove the Content-Length header when using chunked encoding:\n@app.after_request\ndef remove_conflicting_headers(response):\n    if response.headers.get('Transfer-Encoding') == 'chunked':\n        response.headers.pop('Content-Length', None)\n    return response",
    "Use nginx's proxy_hide_header directive to remove the conflicting Content-Length header from upstream responses:\nproxy_hide_header Content-Length;\nThis forces nginx to rely on chunked encoding alone."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_hide_header",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.87,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}