What is HTTP?
HyperText Transfer Protocol (HTTP) is an application-layer Protocol for distributed, collaborative and hypermedia information systems. HTTP is the basis for data communication on the World Wide Web.
HTTP protocol is the basic protocol of the Internet, but also the necessary knowledge of web development, the latest version of HTTP/2 is to make it become a hot technology.
How do you understand this concept? Hypertext transfer protocol? What is it?
First of all, it’s a transport protocol, which is basically a specification of a way to move data from one place to another, and everybody moves data around the network according to this specification. And this norm that everyone follows becomes an agreement.
Second, what is hypertext?
Hypertext is text and text-related content that can be displayed on a computer monitor or other electronic device. The text contains hyperlinks to other fields or documents, allowing you to switch directly from the current reading position to the text to which the hyperlink points
The principle of
HTTP is an application layer protocol based on TCP/IP. It does not involve packet transmission and mainly defines the communication format between the client and the server. Port 80 is used by default.
Execute the process
- The client (browser) sends a request through the URL, for example, www.baidu.com. Baidu.com resolves the corresponding IP address through the DNS.
- TCP/IP Adds IP to data for transmission to Ethernet.
- The TCP connection is established after the TCP three-way handshake
- The server responds to the client.
HTTP features
- 1. Support client/server mode.
- 2. Simple and fast: when customers request services to the server, they only need to transmit the request method and path. The commonly used request methods are GET, HEAD and POST. Each method specifies a different type of contact between the client and the server. Because HTTP protocol is simple, the HTTP server program size is small, so the communication speed is very fast.
- 3. Flexibility: HTTP allows the transfer of any type of data object. The Type being transferred is marked by content-Type.
- 4. Connectionless: Connectionless means that only one request can be processed per connection. The server disconnects from the customer after processing the request and receiving the reply from the customer. In this way, transmission time can be saved.
- Stateless: HTTP is a stateless protocol. Stateless means that the protocol has no memory for transaction processing. The lack of state means that if the previous information is needed for subsequent processing, it must be retransmitted, which can result in an increase in the amount of data transferred per connection. On the other hand, the server responds faster when it doesn’t need the previous information.
history
HTTP / 0.9
The earliest release was version 0.9 in 1991. This version is extremely simple, with a single command GET.
GET /index.html
Copy the code
After the TCP connection is established, the client sends a request to the server for webpage index.html.
According to the protocol, the server can only respond to strings in HTML format, and no other format.
<html>
<body>Hello World</body>
</html>
Copy the code
The server closes the TCP connection after sending the packet.