HTTP request process (TCP three-way handshake and four-time disconnection) and status code

What happens when you enter a website in the browser address bar?

1 Perform domain name resolution on the website to get the IP address.
2 Initiate a TCP request to the WEB server via IP, and establish a TCP connection after three handshake
3 The browser initiates an HTTP request
4 The server responds to the HTTP request and returns HTML code
5 The browser parses the HTML code and requests the resources in the HTML code
6 Browser utilization Its internal working mechanism renders the requested static resources and HTML code and presents it to users.
7 Close the TCP connection

TCP three-way handshake

The first handshake: The client sends a SYN packet (seq=x) to the server, and enters the SYN_SEND state, waiting for the server to confirm.
The second handshake: the server receives the SYN packet, must confirm the client's SYN (ACK=x+1), and at the same time send a SYN packet (seq=y), that is, the SYN+ACK packet, and the server enters the SYN_RECV state
. Three-way handshake: The client receives the SYN+ACK packet from the server, and sends an acknowledgement packet ACK (ACK=y+1) to the server. After this packet is sent, the client and server enter the ESTABLISHD state to complete the three-way handshake.
The packet transmitted during the handshake process does not contain data. After the three-way handshake is completed, the client and server formally begin to transmit data. In an ideal state, once the TCP connection is established, the TCP connection will be maintained until any party in the upper communication actively closes the connection.

Wave four times to disconnect

First wave: The active closing party sends a FIN to close the data transfer from the active party to the passive closing party, that is, the active closing party tells the passive closing party that I will no longer send you messages (of course, in FIN For the data sent before the packet is sent, if the corresponding ACK message is not received, the actively closing party will still retransmit the data), but at this time the actively closing party can still receive the data.
The second wave: After the passive closing party receives the FIN packet, it sends an ACK to the other party to confirm the sequence number +1 (same as SYN, one FIN occupies one sequence number).
Third wave: The passive closing party sends a FIN to close the data transfer from the passive closing party to the active closing party, which is to tell the active closing party that my data has been sent out and will not send you any more data.
Fourth wave: After the active closing party receives the FIN, it sends an ACK to the passive closing party to confirm that the serial number is the received serial number +1. So far, four waves are completed.

2XX success

Indicates that the response result was processed normally

200 OK

The request from the client is processed normally by the server

204 No Content

The request received by the representative server has been successfully processed, and the response message returned does not contain the body of the entity. Such as: the browser will not update.

206 Partial Content

Indicates that the client made a range request and the server successfully executed the GET request.

3XX redirect

Indicates that the browser needs to perform some special processing to properly process the request.

301 Moved Permanently

Permanent redirection. Indicates that the requested resource has been assigned a new URI.

302 Found

Temporary redirection. Indicates that the requested resource has been assigned a new URI, and the user is using it this time. Prevent POST from becoming GET.

303 See Other

Indicates that the resource corresponding to the request has another URI, and the GET method should be used to obtain the requested resource.

304 Not Modified

Indicates that when the client sends a conditional request, the server allows the request to access resources.

307 Temporary Redirect

Temporary redirection. Will not change from POST to GET.

4XX client error

400 Bad Request

Indicates that there is a syntax error in the request message.

401 Unauthorized

Indicates that the request sent requires authentication information that has passed HTTP authentication. If the request has been made once before, it means that the user authentication has failed.

403 Forbidden

Indicates that access to the resource was denied by the server.

404 Not Found

Indicates that the requested resource cannot be found on the server.

5XX server error

500 Internal Server Error

Indicates that the server encountered an error while executing the request.

503 Service Unavailable

Indicates that the server is temporarily overloaded or is being shut down for maintenance, and cannot process requests now.

The difference between URI and URL

URI Uniform Resource Identifier
URL Uniform Resource Locator
URN Uniform Resource Name Uniform Resource Name

Guess you like

Origin blog.csdn.net/weixin_43663421/article/details/109209985