go protocol_error ai_generated true

http: ContentLength=0 with Body length 0

ID: go/http-missing-content-length

Also available as: JSON · Markdown · 中文
80%Fix Rate
81%Confidence
0Evidence
2024-08-30First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.20 active

Root Cause

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

generic

中文

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

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 50% fail

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

  2. 60% fail

    This changes the semantics of the request.