1.Http Protocol Overview
About the development of the HTTP protocol, a lot of information, no longer repeat, do not understand the small partners can go to search, HTTP messages are divided into request messages and corresponding messages, because HTTP is text-oriented, so in the message each field is some ASCII code, is excerpted from Shehiren Fifth Edition " Computer network, in this paper, according to the two classifications of the message header field to summarize the description.
The material is obtained from the great God, I am only responsible for the summary ~
2.Http Request Message
if (a) in the request message format, divides into the request line, the first line and the entity body (this article does not explain to the entity body, the same as below);
2.1 Request Lines
The request line includes a method, a URL, and a version, respectively, as described below.
Methods: The HTTP protocol request method has get, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, CONNECT, the most common method is get and POST;
URL: The requested Address
Version: Protocol name and version number, for example: http/1.1
2.2 First line
Accept: The type of file the client expects to receive
Accept-encoding: The encoding format that the client can receive. It is to compress and improve the speed of file delivery, the client after receiving the web corresponding link, and then check the file format
Accept-languages: The type of language the client expects to receive
Cache-control:
Connection: Used to inform the server whether it can maintain a fixed HTTP connection, including Upgrade,keep-alive and close. http/1.1 uses keep-alive as the default, ensuring that the browser does not need to establish a connection every time when multiple files are required. After you use close, the server disconnects from the client.
Host: The requested target host
Cookies: This field is commonly used when developing, and it is generally used when the shopping cart effect is implemented. As for how cookies work, the article will be explained in detail at the end.
User-agent:user-agent is part of the HTTP protocol and is part of the header domain, and the User Agent is also referred to as UA. In a more general sense, it is an identification of the type of browser you are using, the operating system and version, the type of CPU, the browser rendering engine, the browser language, the browser plugin, and so on, to access the site. For details, please refer to: http://blog.csdn.net/rj042/article/details/6991441
Upgrade-insecure-requests: Security-related Settings
If-modified-since:
3.Http Response Message
4.Cookie Working principle
The cookie works like this:
When a user browses a Web site that uses cookies, the site's server generates a unique identifier for the user, which is used as an index to generate a project in the server's backend database. and in the HTTP corresponding message to the user to add a header called Set-cookie, where the "first field name" is "Set-cookie", the corresponding field value is the server assigned to the user's "identification code." The format is as follows:
SET-COOKIE:ABCDEFG (only as an example, actually certainly more complex than this)
When the user receives this response, his browser adds a line to the specific cookie file he manages, including the server's hostname (that is, the host field) and the identifier of the Set-cookie, which is placed in the cookie header line of the HTTP request message, as follows:
Cookie:abcdefg
The above is the entire cookie process, the site can follow the cookie value of the user's activity on the site, if the site is a shopping site, then the server can be a cookie for the user to maintain a shopping list, so that users can end this shopping together to pay.
Summary of characters commonly used segments in HTTP protocol (not timed perfect)