Let's look at the process of Web resource access:
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/58/77/wKiom1Sx2OahiPF_AAtoHnyzQfY870.jpg "title=" Web resource access graph. png "alt=" wkiom1sx2oahipf_aatohnyzqfy870.jpg "/>
Web Resource Access Graph
What is the HTTP protocol?
After the client connects to the Web server, to obtain a Web resource in the Web server, a certain communication format is required, and the HTTP protocol is used to define the format in which the client communicates with the Web server.
(Install IE browser plugin httpwatch, view IE browser to get a page via HTTP protocol)
Introduction to the HTTP protocol
HTTP is shorthand for the Hypertext Transfer Protocol (Hypertext Transfer Protocol), an application layer of the TCP/IP protocol that defines the process of exchanging data between a Web browser and a Web server.
HTTP protocol version: http/1.0 http/1.1 Difference
In the HTTP1.0 protocol, after a client has established a connection with a Web server, only one web resource can be obtained .
The HTTP1.1 protocol allows a client to obtain multiple Web resources on a connection after it has established a connection with the Web server.
After the client connects to the server, it requests a Web resource from the server, which is called the client sends an HTTP request to the server.
A complete HTTP request consists of a request line, a number of request headers, and entity content.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/58/77/wKiom1Sx21vSnH9mAAIZYlfx30M030.jpg "title=" Http.png "alt=" Wkiom1sx21vsnh9maaizylfx30m030.jpg "/>
HTTP Request Example Diagram
Request Line:
Common request methods are: GET, POST
By default, the browser sends a GET request to the server, and the user can change the form submission by changing the way the request changes to post
1, if the request method is get mode, you can be the requested URL address after the? In the form of a server data, multiple data separated by &, such as: get/mail/1.htmlname=a&password=123 http/1.1.
Get mode features: The parameters that accompany the URL address are limited, and their data capacity typically cannot exceed 1K.
2, if the request mode is post, you can send data to the server in the requested entity content.
Post mode features: The amount of data transmitted is unrestricted.
Request Header:
Accept: Tells the server that the data types supported by the client
Accept-charset: Tells the server that the encoding used by the client
Accept-encoding: Tells the server that the client supports the compression format
Accept-language: The language environment of the client
Host: The client tells the server through this header that it wants to access the host name
If-modified-since: The client tells the server through this header that the cache time of the resource
Referer: The client tells the server through this header which resource to access the server (anti-theft chain)
User-agent: The client tells the server through this header that the client's software environment
Cookies: This header allows the client to bring data to the server
Connection: Whether to keep the connection (keep-alive) or close the connection after the request (close)
An HTTP response represents the data that the server sends back to the client, including: status lines, several corresponding headers, entity content
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/58/77/wKiom1Sx22zy2PLgAAHDrCAoHOM598.jpg "title=" HTTP response. png "alt=" wkiom1sx22zy2plgaahdrcaohom598.jpg "/>
HTTP Response Sample Diagram
Response header:
Location: This header is used with 302 status code to tell the user who to look for
Server: Servers through this header, tell the browser the type of server
Content-encoding: The server through this header, tells the browser data compression format
Content-length: The server passes this header and tells the browser the length of the loopback data
Content-type: The server passes this header and tells the browser the type of loopback data
Last-modified: The server through this header, tells the browser the current resource cache time
Refresh: The server uses this header to tell the browser how often to refresh
Content-disposition: The server uses this header to tell the browser to open the data in the following way
Transfer-encoding: The server passes this header and tells the browser how the data is transmitted
ETag: The head of the cache phase header
Expires: The server passes this header, telling the browser how long to cache the loopback resource, 1 or 0, not the cache
Cache-control:no-cache
Pragma:no-cache
Server through the above two headers, also control the browser do not cache data
HTTP request Header field: The range header indicates that the server transmits only a subset of the resources, which can be used to implement the breakpoint continuation function.
Key to mastering HTTP protocol