Content-Length:HTTP 报文头字段,表示消息体(body)的字节长度(十进制)。常用于让接收方知道需要读取多少字节;在某些情况下会被 Transfer-Encoding: chunked 等机制取代或影响其使用。(该词也可泛指“内容长度”,但最常见语境是 HTTP 头。)
/ˈkɑn.tent lɛŋkθ/
The server returned a Content-Length of 512.
服务器返回的 Content-Length 是 512。
If Content-Length is wrong, the client may hang while waiting for more data or stop early and truncate the response.
如果 Content-Length 不正确,客户端可能会在等待更多数据时卡住,或过早停止从而截断响应内容。
由 content(内容) + length(长度) 组合而成,用来直观表达“内容的长度”。作为标准化术语,它在早期 HTTP 规范中被定义为报文头字段,用于指明消息体大小,便于传输与解析。