How should an HTTP client properly parse *chunked* HTTP response body?

前端 未结 2 972
难免孤独
难免孤独 2021-01-01 21:26

When chunked HTTP transfer encoding is used, why does the server need to write out both the chunk size in bytes and have the subsequent chunk data end with

2条回答
  •  伪装坚强ぢ
    2021-01-01 21:52

    The CRLF after each chunk is probably just for better readability as it’s not necessary due to the chunk size at the begin of each chunk. But the CRLF after the “chunk header” is necessary as there may be additional information after the chunk size (see Chunk Transfer Encoding):

          chunk          = chunk-size [ chunk-extension ] CRLF
                           chunk-data CRLF
    

提交回复
热议问题