Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between multipart and chunked protocol

Tags:

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?

like image 492
user776635 Avatar asked Dec 02 '13 18:12

user776635


People also ask

Why chunked encoding is used?

Chunked encoding allows the sender to send additional header fields after the message body. This is important in cases where values of a field cannot be known until the content has been produced, such as when the content of the message must be digitally signed.

What is chunked message?

Chunked transfer-coding, also known as chunking, involves transferring the body of a message as a series of chunks, each with its own chunk size header. The end of the message is indicated by a chunk with zero length and an empty line.

What is chunked Java?

Chunked responses Chunked transfer encoding is a data transfer mechanism in version HTTP 1.1 in which a web server serves content in a series of chunks. This uses the Transfer-Encoding HTTP response header instead of the Content-Length header, which the protocol would otherwise require.


2 Answers

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.

like image 190
jayadev Avatar answered Oct 19 '22 09:10

jayadev


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.

like image 32
doog abides Avatar answered Oct 19 '22 10:10

doog abides