Principle of Http message operation (1)

Source: Internet
Author: User

Principle of Http message operation (1)

HTTP Request Message anatomy

The HTTP Request Message consists of three parts (request line + Request Header + Request body ):

 

The following is an actual request message:

 

① Is the request method. GET and POST are the most common HTTP methods. In addition, they include DELETE, HEAD, OPTIONS, PUT, and TRACE. However, most browsers currently only support GET and POST. Spring 3.0 provides a HiddenHttpMethodFilter, you can specify these special HTTP methods through the form parameters of "_ method" (in fact, the form is submitted through POST ). After the HiddenHttpMethodFilter is configured on the server, Spring will simulate the corresponding HTTP method Based on the value specified by the _ method parameter. In this way, you can use these HTTP methods to map the processing method.

② It is the URL corresponding to the request. It is a complete request URL consisting of the Host attribute of the packet header, and ③ it is the protocol name and version number.

④ It is the HTTP packet header. the packet header contains several attributes in the format of "attribute name: attribute value". The server obtains the client information accordingly.

⑤ Is a newspaper style. It encodes the component values in a page form into a formatting string through the key-value pairs of param1 = value1 1_m2 = value2, it carries data of multiple request parameters. Not only does the reporting style pass request parameters, but the request URL can also be passed through a URL similar to "/chapter15/user.html? Param1 = value1 then m2 = value2.

Based on the above request message, we further break it down. You can see a more detailed structure:

 

Reference

HttpWatch is a powerful web page data analysis tool. After installation, it will be integrated into the Internet Explorer toolbar. It can capture the complete information of requests and responses, including Cookies, message headers, query parameters, response packets, and so on without a proxy server or some complex network monitoring tools, is a necessary tool for Web application developers.

HTTP Request Header attributes

What is the packet header attribute? Let's explain it in a short story.

Reference

At noon, Zhang Sanfeng didn't want to go to the dining room for dinner, so he called for takeout: Boss, I want a [Fish-flavored shredded meat]. I want to send it to me before. I am at the R & D department of jianghu Lake company, it is called Zhang Sanfeng.

Here, you want to [Fish shredded meat] to be equivalent to the HTTP style, and "sent before", your name is "Zhang Sanfeng" and other information is equivalent to the HTTP header. They are affiliated information to help you and the hotel owner complete the transaction smoothly.

The request HTTP message and response HTTP message both have several packet-related attributes, which are ancillary information to assist clients and servers in transaction.

Common HTTP Request Header attributes

Accept

A request message uses an "Accept" header to indicate the type of response that the server client receives.

The following message header is equivalent to telling the server that the response type that the client can accept is only plain text data. Do not send any other images or videos, so I will take a break ~~~ :

Accept:text/plain

The value of the Accept attribute can be one or more MIME type values, about the MIME type.

Cookie

The Cookie of the client is sent to the server through this packet header attribute! As follows:

Cookie: $Version=1; Skin=new;jsessionid=5F4771183629C9834F8382E23BE13C4C

How does the server know that multiple client requests belong to one Session? Note that the jsessionid = 5F4771183629C9834F8382E23BE13C4C wood in the background has? It was originally associated with the jsessionid value of the Cookie attribute of the HTTP request header! (You can also include the session ID after each URL by rewriting the URL ).

Referer

Indicates the URL from which the request is sent. If you search for a merchant's advertisement page through google, you are interested in this advertisement page, send a request message to the merchant's website, the request message Referer packet header attribute value is http://www.google.com.


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.