Wechat official account: [Dafront-end Yizhan] Follow Dafront-end Yizhan. Questions or suggestions, welcome the public account message.
This is the 26th day of my participation in the August Text Challenge.More challenges in August
HTTP can transmit data directly as it is, but it can also increase the transmission rate through encoding during transmission. A large number of access requests can be efficiently handled by encoding at transport time. However, the operation of coding requires the computer to complete, so it will consume more RESOURCES such as CPU.
Difference between the packet body and entity body
- Message: The basic unit of HTTP communication. It consists of an 8-bit ocTET sequence (ocTET is eight bits) and is transmitted over HTTP communication.
- Entity: Payload data (supplementary items) is transmitted as a request or response, and its content consists of a real body header and an entity body.
HTTP packet body The body of the entity used to transmit the request or response.
Generally, the message body is equal to the entity body. Only when the encoding operation is carried out in transmission, the content of the entity body changes, causing it to be different from the packet body.
Compressed transmission of content encoding
When adding an attachment to a message to be sent, in order to reduce the size of the message, we ZIP the file first and then add the attachment to send. A feature of the HTTP protocol called content encoding can do something similar.
Content encoding specifies the encoding format to be applied to entity content and keeps entity information compressed as is. The encoded entity is received and decoded by the client.
Commonly used content encoding is as follows:
- Gzip (GNU Zip)
- Compress (Standard compression for UNIX systems)
- Deflate (zlib)
- Identity (no coding)
Split transmit block transmission code
During HTTP communication, the browser cannot display the requested page until all the encoded entity resources are transferred. When transferring large amounts of data, the browser can gradually display the page by dividing the data into multiple pieces.
This ability to block entity bodies is called Chunked Transfer Coding.
Chunking transfer coding divides the entity body into parts (blocks). Each block is marked with a hexadecimal size, while the last block of the entity body is marked with “0(CR+LF)”.
The entity body that uses the chunking transfer encoding is decoded by the receiving client and reverts to the entity body before encoding.
There is a mechanism called Transfer Coding in HTTP/1.1, which can be transmitted in a certain encoding mode during communication, but is only defined for block Transfer encoding. ~~ Thanks for watching
[Share, like, watch] Let more people join us