difference between multipart and chunked protocol

user776635 picture user776635 · Dec 2, 2013 · Viewed 13.4k times · Source

Can some experts explain the differences between the two? Is it true that chunked is a streaming protocol and multipart is not? What is the benefit of using multipart?

Answer

jayadev picture jayadev · May 20, 2014

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.