Http encoding chunked and chunked

Source: Internet
Author: User

Http encoding chunked and chunked

I was not very concerned about this. This chunked is enabled by default on nginx, but not on apache. So when switching the server, I also encountered this problem, garbled data is found.

I can find out what the http header is, but it is not very clear.


Check the chunked code carefully.

Data Representation rules transmitted by http in trunked Encoding

Generally, Content-Length header information is used to specify a small value for HTTP Communication, but sometimes the information size cannot be determined, it is necessary to use trunked encoding to dynamically provide the Length of body Content.

The HTTP data transmitted by Chunked encoding must be set in the message header:

Transfer-Encoding: chunked

Indicates that the Content Body will be transmitted using chunked encoding.

Chunked encoding is generally made up of several chunks. It ends with a chunk with a length of 0.
Each chunk is dividedHeaderAndBodyTwo parts,
Header contentSpecify the total number of characters (a hexadecimal number starting with a non-zero character) and the number unit (usually not written, indicating bytes) of the next body ).
BodyIs the actual content of the specified length. The two parts are separated by carriage return line breaks (CRLF.
In the last chunk with a length of 0, the content is called footer, which is some additional Header information (which can be ignored directly ). The specific chunk encoding format is as follows:

The chunked decoding process in RFC is as follows:

The nginx server disables chunked encoding:

Chunked_transfer_encoding off;


Reference link:

Http://www.6san.com/759/

Http://www.sunnyu.com /? P = 175

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.