First Entry Network series notes (3) The simplest grasp of the HTTP protocol

Source: Internet
Author: User

First, the reference note, this blog post for reference to the following

1.starok,http must know, http://www.cnblogs.com/starstone/p/4890409.html

2.careyson,http Agreement on the discussion, http://www.cnblogs.com/CareySon/archive/2012/04/27/HTTP-Protocol.html

3. The cold, analysis of the HTTP protocol, http://www.cnblogs.com/gpcuster/archive/2009/05/25/1488749.html

4.chance_yin,http http request, http://www.cnblogs.com/yin-jingyu/archive/2011/08/01/2123548.html

Second, the HTTP protocol

    • Classification of messages

HTTP messages (some of which are called messages) are divided into two basic categories: Request message and Response message. Where the request message is the message that the client sends to the server to request the service and the resource, the response message is the server's answer to the request message. In general, a response corresponds to a request, not many and many.

    • Features | No connection, no status

The HTTP protocol has been summed up as a non-connected , stateless feature:

1. No connection: The meaning of no connection is to limit the processing of only one request per connection. When the server finishes processing the customer's request and receives the customer's answer, the connection is disconnected. In this way, the transmission time can be saved.

2. Stateless: The HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory capacity for transactional processing. A lack of state means that if the previous information is required for subsequent processing, it must be re-routed, which may cause the amount of data to be transferred per connection to increase. On the other hand, it responds faster when the server does not need the previous information.

    • Basic format of message

The format of the request and response messages for the HTTP protocol is similar. Refining their commonalities, it can be noted that the HTTP message is divided into three parts:

1. First line

2. Head (header)

3. Text (body)

The header is used to indicate some properties of the HTTP message, they have a fixed format, the body part is the actual content of the transmission, their format is arbitrary, usually with the Content-type header to specify. The first line has a slightly different format in the request message and response message, and they represent the most basic part of the HTTP message. Whether it's HTTP or HTTP, the first line is there, or an unforgivable parsing error occurs, but the head and body are optional, but the actual process involves some basic head.

HTTP messages are primarily ASCII-encoded message entities. The main meaning is that the first line and the head are ASCII encoded, and the body part of the code appears arbitrary. In the actual development, the text message sent will often encounter garbled problem. One workaround is that for text messages, the conventions are encoded and decoded in UTF-8 format.

HTTP messages are upper-layer application protocols based on the TCP protocol. TCP protocol is a kind of network flow protocol. In an abstract way, it is an orderly transfer of one byte from one host to another. For the HTTP protocol, Nature maintains this ordering, which is transmitted in the order of the first row , head , and body . The first line and the head are all ASCII text streams, and the body part is the byte stream. A special control structure CRLF is used to control the end of each part.

Note: CRLF is the carriage return and newline character, which are two special ASCII characters. The CR is a carriage return (\ r), the encoding in ASCII is 13;LF is the newline character (\ n), and the encoding in ASCII is 10.

First Entry Network series notes (3) The simplest grasp of the HTTP protocol

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.