HTTP request message

Source: Internet
Author: User

1. HTTP request message Format   First, look at the message format of the HTTP request message, as shown in:  the first line is the request line, the request line has 3 fields, the Method field, the URL field, and the HTTP version field. Method fields can take values of Get, POST, HEAD, put, and delete, and most requests use the Get method. The following line is called the first row. When you use the Get method, the entity body is usually empty, and when you use the Post method, the entity body is usually the content that needs to be post to the server, for example, the data that we enter on the Web page.   below, give a real HTTP request message, as follows: Get/xxx/page.html http/1.1host: www.xxx.comconnection:closeuser-agent:mozilla/ 4.0accept-language:fr  correspondence, the first line of this message represents the request line, the browser requests an object from the server, uses the Get method, its address is in the URL field, is/xxx/page.html, and the HTTP version used is 1.1.   The rest of the behavior header line, preceded by the first field name, followed by the value of the field. host: www.xxx.com  defines the host on which the target resides, and the information provided by the header row is required by the Web Proxy cache. Connection:close it tells the server that it does not want to use persistent connections, it requires the server to close the connection after the requested object has been sent. User-agent:mozilla/4.0 is used to define the user agent, the type of browser that sends requests to the server, which is the Netscape browser. ACCEPT-LANGUAGE:FR indicates that the user wants the French version of the object.  2, HTTP Response message Format  http Response message format and HTTP request message is a bit different, HTTP response message format as shown in:  we can see it is also composed of three parts, the first behavior of the state line, followed by the head of the line, The final is the entity body to be sent. The entity body part is the body of the message, that is, it contains the requested object itself.   below to see a real HTTP response message, as follows: http/1.1, OKConnection:closeData:Thu, Jul, 00:00:00 gmtserver:apache/1.3.0 (Un IX) Last-modified:sun, 6, May 09:23:24 Gmtcontent-type:text/html  (Data ...)   First take a look at the first line, it corresponds to the status line, in the message, the status line indicates that the server uses the protocol is http/1.1, the status code is 200, the phrase is OK, indicating everything is normal, the information is contained in the returned response message. The first line of the   2nd to 5th behavior, Connection:close tells the client to close the TCP connection after the message is sent. The Data header line indicates the date and time that the server generated and sent the response message, which is the time that the server retrieved the object from its file system and inserted it into the response message.  server The first line indicates that the message was generated by an Apache web server, similar to the User-agent header line in the request message. The Last-modified header line indicates the time and date when the object was created or last modified. The Content-type header row indicates the file type of the object in the entity body, and the object type should be used formally instead of the file extension, because in some systems (such as Linux), the file type is not distinguished by the extension. The  content-length header row indicates the number of bytes of the object being sent.  3, common HTTP status codes and phrases: The request succeeds, and the information is contained in the returned response message. 301 Moved Permanently: The requested object has been permanently transferred, and the new URL definition is specified in the Location header row of the response message. The client can automatically get the object with a new URL. Repuest: A generic error code that indicates that the request cannot be understood by the server. 404 Not Found: The requested document is not on the server. 505 HTTP Version not supported: The HTTP protocol version used by the request message is not supported by the server.

HTTP Request message

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.