HTTP Definition
HTTP ???? The Hypertext Transfer Protocol is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web.
Hypertext Transfer Protocol (HTTP) is a rule that specifies the communication between browsers and web servers.
HTTP is the application layer protocol in the TCP/IP Model ????????
As a transmission protocol, HTTP also evolves over time like HTML. Currently, http1.1 is the third version of the HTTP protocol and is a persistent connection by default.
HTTP is a stateless connection-oriented protocol. Stateless does not mean that HTTP cannot maintain a TCP connection, nor does it mean that HTTP uses a UDP Protocol (No connection)
Starting from HTTP/1.1, keep-alive is enabled by default to maintain the connection feature. To put it simply, after a webpage is opened, the TCP connection between the client and the server for transmitting HTTP data will not be closed. If the client accesses the webpage on the server again, it will continue to use this established connection. Keep-alive does not keep the connection permanently. It has a retention time, which can be set in different server software (such as APACHE.
?
HTTP request and response
The following uses a browser to access the Baidu homepage,Www.baidu.com
- The client (browser) sends a request to get the http://www.baidu.com's HTML;
The server sends the response back to the browser.
- HTML in browser Response Analysis (response), which references many other files, slice, CSS, JS, etc.
- The browser will automatically send a request again to obtain the image, CSS, or JS
- After all the files are downloaded successfully, the web page is fully displayed.
All the above HTTP requests rely on only one TCP connection, which is called a persistent connection.
Request and Response Details:
The so-called HTTP request, that is, the Web Client sends information to the Web server;
After an HTTP request is received, some processing is performed based on the request information and an HTTP response is returned accordingly.
(These operations may only be static return pages, or are returned after processing in languages such as Asp.net, PHP, and JSP)
|
HTTP Request |
HTTP Response |
|
Request Line
HTTP Header
Content |
Status line
HTTP Header
Returned content |
?
|
HTTP request line |
HTTP response status line |
|
Get |
Www.baidu.com |
HTTP/1.1 |
HTTP/1.1 |
200 |
OK |
|
Request Method |
URL |
Version |
Version |
Status Code |
Status description |
Request Line
Composition :???? Request Method + URL + version
Request Methods: Common get and post methods. There are many actual HTTP request methods, such as put, delete, Head, connect, and trace methods. Perform Bing on your own;
Status line
Composition :???? Version + status code + status description
Status Code: The meaning of the HTTP status code is explained. The categories are as follows. For details, see the HTTP response status code.
- Information (100-199)
- Response successful (200-299)
- Redirection class (300-399)
- Client errors (400-499)
- Server errors (500-599)
HTTP Header
HTTP request:Request Header; General header; entity Header)
HTTP response:Response Header; General header; entity Header)
General header )???????? Describes the HTTP protocol. For example, whether the HTTP connection is persistent or not; the date header of the sending date; the keep-alive header of the TCP connection time; the cache-control class
Entity Header)???????? The header that describes the HTTP information. It can be either in the http post method request or in the HTTP response. For example, both Content-Type and Content-Length describe the object type and size headers belong to the object header. There are other content-language, Content-MD5, content-encoding, and expires and last-modifies headers used to describe entities
Request Header)???? Is sent by the client to the server, so that the server can better meet the client request header. The request header can only appear in an HTTP request. For example, tell the server to only receive the accept header of a response content; send the cookie header of cookies to display the host of the Request Host domain; Use the cache if-match, if-match-since, if-None-match header, used to retrieve only the range header of part of the HTTP Response Information, used to attach the referrer header referenced by HTML-related requests
Response Header)???? The HTTP response header is the header describing the HTTP Response itself. It does not contain the header describing the third part of the HTTP response, that is, the HTTP information (this part is the responsibility of the entity header ). For example, if the refresh header is refreshed on a regular basis, the retry-after header is automatically retried when a 503 error occurs, the server header that displays the server information, and the set-Cookie header of the cookie is set, tell the client that some requests can be sent to the accept-ranges class (for more information about the above HTTP headers, see the HTTP header)
Content
The HTTP request content only exists in the POST request, and the GET request does not contain any entity. This is the essential difference between post and get.
The HTTP Response content is the information requested by the HTTP request. This information can be HTML or an image.
HTTP status persistence
The HTTP protocol is stateless, that is, the server does not know whether each request comes from the same client. Therefore, the following measures are required to maintain the status.
Keep status through cookies
To solve this problem, the HTTP protocol can maintain the status through cookies.
Maintain status using form variables
In addition to cookies, you can also use form variables to maintain the State. For example, Asp.net uses a box named viewstate input = "hidden" to maintain the State. For example:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMjA0OTM4MTAwNGRkXUfhlDv1Cs7/qhBlyZROCzlvf5U=" />
??? This principle is similar to cookies, but the information contained in each request and response is changed to form variables.
Keep status through querystring
This principle is the same as the above two State persistence methods. querystring transfers information to the server by saving the information at the end of the requested address. It is usually used in combination with a form, A typical querystring is as follows:
????www.xxx.com/xxx.aspx?var1=value&var2=value2
?
?
HTTP protocol (I) Overview