Length" field in HTTP header?

What does it mean?

  • Byte count of encoded content string with encoding specified in header.
  • Character count of content string.
  • Especially in case of "Content-Type: application/x-www-form-urlencoded".


    rfc2616

    The Content-Length entity-header field indicates the size of the entity-body,
    in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD
    method, the size of the entity-body that would have been sent had the request
    been a GET. 
    

    It doesn't matter what the content-type is.

    Extension at post below.


    It's the number of bytes of data in the body of the request or response. The body is the part that comes after the blank line below the headers.


    The Content-Length header is a number denoting an the exact byte length of the HTTP body. The HTTP body starts immediately after the first empty line that is found after the start-line and headers.

    Generally the Content-Length header is used for HTTP 1.1 so that the receiving party knows when the current response* has finished, so the connection can be reused for another request.

    * ...or request, in the case of request methods that have a body, such as POST, PUT or PATCH

    Alternatively, Content-Length header can be omitted and a chunked Transfer-Encoding header can be used.

    If both Content-Length and Transfer-Encoding headers are missing, then at the end of the response the connection must be closed.

    链接地址: http://www.djcxy.com/p/71832.html

    上一篇: HTTP / 2响应标题字段不在Google Chrome中的Pascal案例中

    下一篇: HTTP标头中的“长度”字段?