20.14 Content-Length The Content-Length header field indicates the size of the message-body, in decimal number of octets, sent to the recipient.Applications SHOULD use this field to indicate the size of the message-body to be transferred, regardless of the media type of the entity. If a stream-based protocol (such as TCP) is used as transport, the header field MUST be used. Content-Length报头字段指示发送给收件人的消息体的大小,以十进制八位字节为单位。无论实体的媒体类型如何,应用程序都应该使用此字段来指示要传输的消息体的大小。如果使用基于流的协议(如TCP)作为传输,则必须使用报头字段。 The size of the message-body does not include the CRLF separating header fields and body. Any Content-Length greater than or equal to zero is a valid value. If no body is present in a message, then the Content-Length header field value MUST be set to zero.
消息体的大小不包括分隔报头字段和正文的CRLF。任何大于或等于零的“Content-Length”都是有效值。如果消息中不存在消息体,则Content-Length报头字段值必须设置为零。
The ability to omit Content-Length simplifies the creation of cgi-like scripts that dynamically generate responses. 省略Content-Length的功能简化了动态生成响应的类cgi脚本的创建。 The compact form of the header field is l. 报头字段的紧凑形式是l。 Examples: 示例: Content-Length: 349 l: 173