Before you make a little summary of the HTTP protocol, review the network structure:
1, OSI seven layer network structure: ISO (international Organization for Standardization) developed an Internet standard framework model, called the development system Interconnection basic Reference Model. bottom-up is: Physical layer, Data Link layer, Network layer (IP protocol), Transport Layer (TCP, UDP protocol), session layer, presentation layer, application layer (http protocol, telnet protocol, ftp protocol, etc.). The basis of division should be each layer different function, function, each layer also should have different agreement.
2. Simplified TCP/IP protocol: Four layer, network interface layer (corresponding to physical layer and data Link layer), Network layer, Transport layer, Application Layer (corresponding session layer, presentation layer and application Layer)
3, the understanding of each layer: the role of the physical layer is to consider the bitstream information and physical information (current Voltage) How to correspond, there are some physical equipment how to connect the requirements;
Data link layer function is to provide the link between adjacent nodes for data transmission services, data to be transferred from one host to another, it will go through a section of the link;
The function of network layer is mainly to provide communication service between different hosts in packet switching networks, and some routing strategies help to select appropriate route in data Transmission.
Transport layer is to provide a common data transfer service for the communication between processes in two hosts;
The Application Layer service object is the application process, through the application process interaction to complete the specific network application, the application layer protocol defines the process of communication and interaction between the rules
What is a url?
Url: a Uniform Resource locator is actually a network address that represents the location of a resource on a network that can be accessed through a URL
format:< protocol >://< host address >:< port >/< path >
< host address >:< port > can also be represented by a domain name, such as www.imooc.com, but this will resolve the host address through DNS (domain name System) when requesting the World Wide Web Document.
The default port for HTTP is 80, so URLs that use the HTTP protocol can usually omit the port number, and the path can be omitted, such as http://www.tsinghua.com.cn,
You can also take the path to the document you want to access, such as http://www.tsinghua.com.cn/chn/yxsz/index.htm
HTTP protocol?
HTTP protocol: Hypertext Transfer Protocol. Application Layer protocol, No connection, no status.
The user clicks on a link on the page, the link URL is http://www.tsinghua.com.cn/chn/yxsz/index.htm, the whole process is as follows:
1, Browser Analysis link to the page URL
2, the browser to the domain Name System DNS request resolution www.tsinghua.com.cn IP Address
3, domain Name System DNS resolves the domain name corresponding to the Server's IP address is 166.111.4.100
4, the browser and the server to establish a TCP connection
5. The browser sends an HTTP request to the server (the browser issues a fetch file command: Get/chn/yxsz/index.htm)
6, the server www.tsinghua.com.cn give the response, the file index.htm sent to the browser
7. TCP Connection Release
8. The browser displays the text content returned by the server on the page
Although it is necessary to establish a TCP connection before sending the HTTP request to ensure the reliable transmission of the data, the HTTP protocol itself is not connected, that is, no need to send the request message before the connection is Established.
HTTP protocol is stateless, that is, no memory function, even if the same customer to the same server to initiate a second visit, is also a new request, the server will not know how many times the customer has initiated the request, that is, every visit is the same as the first visit.
The HTTP request message is actually sent to the server when the third handshake in the three-time handshake of the TCP connection is made, and the connection is disconnected after the HTTP response message is sent from the server to the Client.
HTTP1.0 and HTTP1.1 Differences: version 1.0 is a non-persistent connection, that is, every request to establish a TCP connection, the next access to re-establish a TCP connection, and the 1.1 version is a continuous connection mechanism, that is, after the server sends a response message, still over a period of time to remain connected for the same customer and the service Can send subsequent requests and response messages, thus saving the overhead associated with establishing a TCP Connection. And some request methods (such as option,put,detele,trace,connect, Etc.) are also increased in 1.1.
Methods for HTTP Requests:
1. GET requests to read the information marked by the URL
2, POST to the server to add information
3. PUT to store a document under the specified URL
4. Delete Deletes the resource indicated by the specified URL
5. HEAD requests to read the header of the information marked by the URL
6. TRACE used for loopback test request message
7. CONNECT for Proxy Server
8. Option Request information for some options
The status code of the response message is 3 digits and is divided into 5 categories of 33 types:
1xx: indicates a notification message, such as a request received or being processed
2xx: indicates success, as accepted or known
3xx: indicates redirection, and further action must be taken to complete the request
4xx: indicates a customer error, such as an incorrect syntax in the request or a failure to complete
5xx: indicates a server error, such as server failure cannot complete the request
Store the User's information on the server?
Cookies can be used in HTTP. What is the mechanism? If a user initiates an HTTP request while browsing a Web site that uses cookies, the server generates a unique identifier for the user and adds this identifier information to the response message returned to the user, for Example: set-cookie:1233435, The browser will then add a line in the cookie text to record the identifier and the host name of the corresponding server, followed by the code in the HTTP request message Sent. This allows the site to track user 1233435 activities on the Site.
About the HTTP protocol