difference between multipart and chunked protocol

笑着哭i 提交于 2019-11-30 08:26:52
jayadev

More intuitively,

Chunking is a way to send a single message from server to client, where the server doesn't have to wait for the entire response to be generated but can send pieces (chunks) as and when it is available. Now this happens at data transfer level and is oblivious to the client. Appropriately it is a 'Transfer-Encoding' type.

While Multi-part happens at the application level and is interpreted at the application logic level. Here the server is telling client that the content , even if it is one response body it has different logical parts and can be parsed accordingly. Again appropriately, this is a setting at 'Content-Type' as the clients ought to know it.

Given that transfer can be chunked independent of the content types, a multi-part http message can be transferred using chunked encoding by the server if need be.

Neither is a protocol. HTTP is the protocol. In fact, the P in HTTP stands for Protocol.

You can read more on chunked and multipart under Hypertext Transfer Protocol 1.1

Chunked is a transfer coding found in section 3.6 Transfer Codings.

Multipart is a media type found in section 3.7.2 Multipart Types a subsection of 3.7 Media Types.

Chunked also affects other aspects of the protocol such as the content-length as specified under 4.4 as chunked must be used when message length cannot be predetermined (mainly when delivering dynamic content).

From 14.41 (Transfer-Encoding header field)

The Transfer-Encoding general-header field indicates what (if any) type of transformation has been applied to the message body in order to safely transfer it between the sender and the recipient. This differs from the content-coding in that the transfer-coding is a property of the message, not of the entity.

Put more simply, chunking is how you transfer a block of data, while multipart is the shape of the data.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!