The story of computer network - HTTP information in HTTP message

HTTP information in the HTTP message


1. HTTP message

HTTP messages are string text composed of multiple lines (CR+LF as line breaks). HTTP messages can be divided into two parts: the message header and the message body. The two parts are initially divided by (CR+LF). , usually does not necessarily have a message body.
Insert image description here

2. Structure of request message and response message

Insert image description here
Explanation of parameters in the message:
Request line: contains request method, request URI and HTTP version.
Status line: response status code, reason phrase, and HTTP version.
There are generally four header fields: general header, request header, response header, and entity header

3. Coding improves transmission rate

Similar to when adding an attachment in an email, in order to make the email smaller, ZIP will be used to compress the file before transmission. Content encoding exists in the HTTP protocol and has a similar function to encode entity content.
The client is responsible for decoding. Commonly used content encodings: gzip (GNU zip), compress (standard compression in UNIX systems).
Chunked transfer encoding for split sending: the function of dividing the entity body into chunks is called chunked transfer encoding. Blocked transmission The encoding is divided into multiple blocks, each block will be marked with the size of the block in hexadecimal, and the last block will be marked with "0(CR+LF)".
Insert image description here
Sending multi-part object collections of various data: Similar to the MIME (Multipurpose Internet Mail Extemsions) function of email transmission, HTTP also uses multi-part object collections. When sending a message, it can contain multiple types of entities, usually pictures or files. Used when uploading.
multipart/form-data is used when uploading files through web forms. Use
multipart/byteranges when the status code 206 response message contains multiple ranges of content. Use
multipart/form-data and multipart/by. Before using strings to separate entities, insert " -" mark to separate.

Insert image description here
Request range to obtain partial content: Partial content of the resource can be obtained. It is suitable for continuing to request resources from the accepted resource after disconnection. Specify a range request
for a resource of 10,000 bytes. If you use a range request, you can only Request resources within 5001~10 000 bytes.

Content negotiation: Returning the most appropriate content involves browser default language, character set, encoding and other settings. The requesting server will return the most appropriate content. Certain header
fields included in the request message are the basis for judgment, such as: Accept , Accept-Charset, Accept-Encode, Accept-Language, Content-Language
content negotiation technology: Server-driven negotiation: Content negotiation is performed by the server Client-
driven negotiation: Content negotiation is performed by the client. The user manually selects from the browser's selectable list.
Transparent Negotiation: A Combination of Server and Client Driven


Guess you like

Origin blog.csdn.net/weixin_45841848/article/details/132680277