HTTP message: For HTTP protocol interaction information, the client's HTTP message is called the request message, the response is called the response message
Essence: A string literal consisting of multirow (with Cr+lf as a newline character) data
Note: CR: Enter, print pin back to the beginning of the line LF: wrap, print pin move to next line
Composition: message header, message body
Message header: The content and properties of the request or response that the server side or client needs to process
Message body: Data to be sent
Request message (upper) response message (bottom)
Request line: Requested method, request URI, HTTP version
Status line: Response result status code, reason phrase, HTTP version
Header field: A variety of headers that represent the various conditions and attributes of a request and response, typically four types (see figure)
Other: Undefined header (cookie, etc.) in RFC containing HTTP
Encoding in HTTP
HTTP can transfer data directly, can also be encoded after the transfer, encoding method can effectively handle a large number of access requests, but the encoding process requires the computer to complete, and therefore consumes more CPU and other resources
Message: The basic unit of HTTP communication, consisting of 8-bit byte streams, transmitted via HTTP communication
Entity: Payload Data (supplementary item) as a request or response is transmitted, and its contents consist of the entity header and the entity body
The body of the message is used to transmit the entity body of the request or response, usually, the message body equals the entity body, and the content of the entity body is changed only when it is encoded in the transmission, which causes it to differ from the message body.
Content encoding in HTTP keeps the entity information compressed as it is, and the content-encoded entities are received by the client and are responsible for decoding
Common content Encoding: gzip Compress deflate identity (not coded)
Transmission encoding mechanism: transmitted in a coded manner during communication, but only defined in the chunked transfer encoding
chunked transfer encoding: When transferring large volumes of data, by splitting the data into chunks, the browser is able to progressively display the page
MIME mechanism in mail: Multi-purpose Internet Mail extensions, support for sending multiple types of files, such as mail, text, pictures, videos, etc., because of the use of a method called a collection of multipart objects
Multi-Part object collection: HTTP also uses a multipart collection, sending a message body can contain a multi-type entity, which contains the following objects:
Multipart/form-data: Used when uploading Web Forms files
Multipart/byteranges: Status code 206 (partial content), when the response message contains multiple ranges of content when used
HTTP GET partial content request
Add Range on request header to delimit request
Example: range:bytes=5001-10000 5001-10000 bytes
Range:bytes=5001-5001 to the back of all bytes
range:bytes=-3000,5000-7000 start to 3000 bytes and 5000 to 7000 bytes
Returns a 206 response message for a status code that returns a status code of OK and full entity content if the server is unable to respond to a range request
HTTP Content Negotiation
The same Web site may have more than the same content of the page, such as English and Chinese version, when the default language of the browser is English or Chinese, access to the same URI Web page will display the corresponding English or Chinese version of the page, such a mechanism called content negotiation
Benchmark: Response resource language, character set, encoding method, etc.
Header field: Accept
Accept-charset
Accept-encoding
Accept-language
Content-language
Technology for content negotiation:
Server-driven negotiation: content filtering by the server
Client-driven negotiation: content filtering by the client, manually selected by the user from the optional list, or using JavaScript to select
Transparent negotiation: Content negotiation by server side and client
http--Study notes (3)