18.3 Framing 18.3 框架 In the case of message-oriented transports (such as UDP), if the message has a Content-Length header field, the message body is assumed to contain that many bytes. If there are additional bytes in the transport packet beyond the end of the body, they MUST be discarded. If the transport packet ends before the end of the message body, this is considered an error. If the message is a response, it MUST be discarded. If the message is a request, the element SHOULD generate a 400 (Bad Request) response. If the message has no Content-Length header field, the message body is assumed to end at the end of the transport packet. 在面向消息的传输(如UDP)的情况下,如果消息具有Content-Length报头字段,则假定消息体包含那么多字节。如果传输数据包中有超出消息体末尾的额外字节,则必须丢弃这些字节。如果传输数据包在消息体结束之前结束,则认为这是一个错误。如果该消息是响应,则必须将其丢弃。如果消息是一个请求,则元素应该生成一个400(坏请求)响应。如果消息没有Content-Length报头字段,则假定消息体结束于传输数据包的末尾。 In the case of stream-oriented transports such as TCP, the Content-Length header field indicates the size of the body. The Content-Length header field MUST be used with stream oriented transports.
在面向流的传输(如TCP)的情况下,Content-Length报头字段指示消息体的大小。Content-Length报头字段必须与面向流的传输一起使用。