Diagram http (iii) HTTP information within a--HTTP message

Source: Internet
Author: User
Tags character set ranges
First, HTTP messages

The content used for HTTP protocol interaction is called an HTTP message. The client's HTTP message is called the request message, and the HTTP message on the server is called the response message. The HTTP message itself is a string literal consisting of multiple rows of data.

The HTTP message can be divided into two pieces of message header and message body, but the message body is not necessary.

The header of a message is the content and attributes of the request or request that the server or client needs to process.

The message body is the data that should be sent. II. structure of request messages and response messages 1. Request Line

Contains the method used for the request, the URI of the request and HTTP version 2, the status line

Contains status codes for response results, reason and HTTP version 3, header fields

Contains the various headers that represent the various conditions and attributes of the request and response. third, the code to improve the transmission rate

HTTP transmits data as it is transmitted, but it can also be encoded to increase the transfer rate during transmission. 1, the difference between the message subject and the entity body

Messages are the basic unit of HTTP communication and consist of 8-bit byte streams.

An entity is a payload data that is transmitted as a request or response, and its contents consist of the entity header and the entity body.

The body of an HTTP message is primarily used to transfer the entity body of a request or response. Typically, the message body equals the entity body. However, when encoding in transit, the content of the entity body changes, causing it to differ from the message body. 2, compressed transmission of content encoding

The content encoding indicates the encoding format applied on the entity content and keeps the entity information compressed as it is, and the content-encoded entity is received and decoded by the client. 3, split transmission of the chunked transfer code

In the HTTP communication process, the requested encoding entity resource has not been fully transferred until the browser cannot display the request page. When transferring large volumes of data, by splitting the data into chunks, the browser is able to display the page progressively. The function of the block transfer of the entity body is called chunked transmission coding.

The chunked transfer encoding divides the entities into blocks, each of which is marked with a 16-based chunk, and the last piece of the entity body is marked with "0". Entity principals that use chunked transfer encoding are decoded by the receiving client and revert to the entity body before the encoding. Iv. Collection of multi-part objects that send multiple data

When sending a message, we write text and add multiple attachments to the message because of the MIME (Multipurpose Internet Mail Extensions, multi-purpose web mail extension) mechanism. In a MIME extension, a method called a collection of multipart objects is used to accommodate multiple copies of different types of data.

The HTTP protocol also incorporates a multi-part object collection, which can contain multiple types of entities within a message body. This is usually used when uploading files or text content. multipart/form-data: Used when uploading Web Forms files



multipart/byteranges: Status Code 206 Response message contains multiple ranges of content when used v. Obtaining a range of content requests

If you encounter a network outage during the download process, we need a feature that resumes downloading from a previous download outage, which requires specifying the scope of the downloaded entity. The request sent by the specified range is called a range request. For example, a 10000-byte resource, if you use a range request, you can request only 5001-10000 bytes of resources.

When a scope request is performed, the header field range is used to specify the byte range of the resource, specified as follows:

5001-10000 bytes
range:bytes=5001-10000//

bytes
range:bytes=5001-

//Multiple ranges after starting from 5001
range:bytes= 0-3000,5000-7000

For a range request, the response returns a response message with a status code of 206. For multiple ranges of range requests, the response will return a response message after the first field Content-type marked Multipart/byteranges. If the server is unable to respond to a range request, the status code of OK and full entity content is returned. Vi. Content Negotiation returns the most appropriate content

Content negotiation refers to the client and the server to negotiate the content of the response, and then provide the most appropriate resources to the client. Content negotiation determines the resources of the response based on language, character set, encoding format, and so on. As follows:

Accept

Accept-charset

Accept-encoding

Accept-language

Content-language

Content negotiation technology has the following three types: 1, server-driven negotiation

The server-side content negotiation, with the request header field as a reference, on the server side automatically processing. 2, client-driven negotiation

Content negotiation by the client, the user from the browser's list of available manual selection, you can also use the JS script on the Web page to automatically select. 3. Transparent negotiation

is a combination of server-driven and client-driven, which is a method of content negotiation by the server and client.

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.