{"record":{"id":"faa3aa2691a94289","repo":"XX-net/XX-Net","slug":"response-length-incorrect-head-len-s-content-le","errorCode":null,"errorMessage":"response length incorrect, head len:%s, content len:%d retry it","messagePattern":"response length incorrect, head len:(.+?), content len:(.+?) retry it","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"code/default/x_tunnel/local/front_dispatcher.py","lineNumber":196,"sourceCode":"            if g.server_host:\n                host = g.server_host\n\n        headers[\"X-Async\"] = \"1\"\n        if len(data) < 84:\n            padding = utils.to_str(utils.generate_random_lowercase(random.randint(8, 64)))\n            headers[\"Padding\"] = padding\n\n        content, status, response = front.request(\n            method, host=host, path=path, headers=dict(headers), data=data, timeout=timeout)\n\n        if status not in [200, 521, 400, 404]:\n            xlog.warn(\"front retry %s%s\", host, path)\n            time.sleep(1)\n            continue\n\n        header_len = int(response.headers.get(b\"Content-Length\", 0))\n        if header_len and len(content) != header_len:\n            xlog.warn(\"response length incorrect, head len:%s, content len:%d retry it\", header_len, len(content))\n            time.sleep(1)\n            continue\n\n        return content, status, response\n\n    return content, status, response\n\n\ndef set_session_host(host):\n    global session_fronts\n    for front in session_fronts:\n        dispatcher = front.get_dispatcher(host)\n        if not dispatcher:\n            continue\n\n        dispatcher.set_session_host(host)\n\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/x_tunnel/local/front_dispatcher.py#L178-L214","documentation":"The response Content-Length header disagrees with the actual bytes read, so the payload is considered truncated/corrupt and the dispatcher retries. Indicates the front connection was cut mid-body or a proxy tampered with the body.","triggerScenarios":"front.request returns content shorter/longer than Content-Length: connection reset mid-transfer, worker buffering bug, or middlebox modifying responses.","commonSituations":"Unstable networks, GFW RST injection on TLS flows, or a front worker with broken chunked handling.","solutions":["Retry (dispatcher already sleeps 1s and retries — usually transient)","Check network stability / try different fronts","If persistent for one front, mark that front domain as bad and update the list"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat Content-Length mismatch as transient; the dispatcher already retries","Avoid flaky networks/fronts for large downloads"],"tags":["x-tunnel","truncated-response","content-length","retry"],"backgroundTag":"truncated-http-response","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}