HTTP working principle and HTTP message summary

Introduction to HTTP

Hypertext Transfer Protocol (Hypertext Transfer Protocol, HTTP) is a simple request-response protocol, which is used to transmit hypertext from the World Wide Web (WWW: World Wide Web) server to the local browser; it usually runs on TCP superior. Transfer data (HTML files, picture files, query results, etc.) based on TCP/IP communication protocol.

How HTTP works

The HTTP protocol works on a client-server architecture. As an HTTP client, the browser sends all requests to the HTTP server, that is, the WEB server, through the URL.
Web servers include: Apache server, IIS server (Internet Information Services), etc.
The default HTTP port number is 80, but you can also change it to 8080 or other ports.

HTTP is based on the client/server model and is connection-oriented. Typical HTTP transaction processing has the following process:
(1) The client establishes a connection with the server;
(2) The client makes a request to the server;
(3) The server accepts the request and returns the corresponding file as a response according to the request;
(4) The client communicates with the server. The server closed the connection.

Three things to note about HTTP:

1. HTTP is connectionless: The meaning of connectionless is to limit each connection to only process one request. After the server finishes processing the client's request and receives the client's response, it disconnects. In this way, transmission time can be saved.
2. HTTP is media independent: This means that any type of data can be sent over HTTP as long as the client and server know how to handle the content of the data. Clients and servers specify content-types using the appropriate MIME-type.
3. HTTP is stateless: The HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory capability for transaction processing. The lack of state means that if subsequent processing needs previous information, it must be retransmitted, which can lead to an increase in the amount of data transferred per connection. On the other hand, when the server does not need previous information, its response is faster.
The following diagram shows the HTTP protocol communication process:

insert image description here

HTTP message

HTTP messages include request messages and response messages.

insert image description here

Guess you like

Origin blog.csdn.net/Maybe_ss/article/details/115362587