Chunked transfer encoding
From Wikipedia, the free encyclopedia
Chunked Transfer Encoding is one way in which an HTTP server may transmit data to a client application (usually a web browser). The data is broken up into a series of blocks of data and transmitted in one or more "chunks" so that a server may start sending data before it knows the final size of the "file" that it's sending. Often, the size of these blocks is the same, but this is not always the case.
HTTP servers sometimes use compression (gzip or deflate) to allow for increased transmission speed. Often, chunked transfer encoding is used to delimit the end of the compressed object. In this case, it is worth noting that the chunks are not individually compressed. Instead, the complete payload is compressed and the output of the compression process is chunked using the scheme described in this article.
[edit] Format
The server sends a Transfer-Encoding response header with chunked as its value. Each chunk starts with the length of its data in hexadecimal notation, followed by carriage return, a linefeed, and the data itself. In some implementations, white space chars (0x20) are padded between chunk-size and CRLF. When there is no more data to send, the response ends with a chunk of length 0.
[edit] Sample response
HTTP/1.1 200 OK Content-Type: text/plain Transfer-Encoding: chunked 23 This is the data in the first chunk 1A And this is the second one 0
See RFC 2616 for further details.