go protocol_error ai_generated true

http: ContentLength=0 且 Body 长度为 0

http: ContentLength=0 with Body length 0

ID: go/http-missing-content-length

其他格式: JSON · Markdown 中文 · English
80%修复率
81%置信度
0证据数
2024-08-30首次发现

版本兼容性

版本状态引入弃用备注
1.20 active

根因分析

服务器期望非零的 ContentLength,但请求体为空,导致协议违规。

English

The server expects a non-zero ContentLength but the request body is empty, causing a protocol violation.

generic

解决方案

  1. 85% 成功率
    Ensure the request body is non-empty or set ContentLength to -1 for chunked encoding.

无效尝试

常见但无效的做法:

  1. 50% 失败

    This can cause the server to read beyond the body and fail.

  2. 60% 失败

    This changes the semantics of the request.