{
  "id": "go/http-header-write-after-write",
  "signature": "http: wrote more than the declared Content-Length",
  "signature_zh": "http：写入的内容超过声明的 Content-Length",
  "regex": "http:\\ wrote\\ more\\ than\\ the\\ declared\\ Content\\-Length",
  "domain": "go",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Handler set Content-Length header explicitly but wrote more bytes than declared, or middleware re-wrote the body.",
  "root_cause_type": "generic",
  "root_cause_zh": "处理程序显式设置了 Content-Length 但写入的字节数超出声明，或中间件重写了 body。",
  "versions": [
    {
      "version": "1.18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.21",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Clients hang waiting for the remaining bytes.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Headers already sent; no effect.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Buffer the response with bytes.Buffer, then set Content-Length to buf.Len() before w.Write.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "Do not set Content-Length manually; let net/http chunk or compute it.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-22",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}