Summary of common knowledge points about HTTP

1. Common knowledge points about HTTP

1. HTTP characteristics

application layer protocol

Features: (1) Support client/server mode

(2), simple and fast

When the client requests services from the server, it only needs to send the request method and path;

Commonly used methods include GET, POST, HEAD, etc.

(3), flexible

Allows transmission of different types of data, Content-Type tag

(4), no connection

Each connection can only handle one request. The server releases the TCP connection immediately after processing the request.

(5), stateless

There is no memory for transaction processing. When the same user accesses the server again, the response page will be the same as the first time.

2. The difference between HTTP GET and POST

(1) Get is generally used for requests; post is generally used for uploading resources.

(2) The get request parameters are in the path and are not safe; the post parameters are in the request body and are safe.

(3) The get request parameter has a length limit. If long content is placed in the URL, the server may not be able to read it;

The post request has no requirements for parameters.

(4) get generates a TCP data packet, the browser sends the http header and data together, and responds with 200;

Post The browser sends the header first, and the server responds with 100 continue. The browser then sends data, and the server responds with 200.

(5) get is harmless when the browser rolls back, while post will submit the request again.

(6) Parameter data type, get only accepts ASCLL characters, while post has no limit.

(7) The get request parameter record will be saved in the history record, and the parameters in post will not be retained.

3. The difference between HTTP and HTTPS

(1) HTTP is a clear text transmission, the data is unencrypted, and has poor security. HTTPS (SSL+HTTP) data transmission process is encrypted and has good security.

(2) Using the HTTPS protocol requires applying for a certificate.

(3) HTTP page response speed is faster than HTTPS. Because HTTP uses TCP three-way handshake to establish a connection, three packets are exchanged between the client and the server, and HTTPS plus SSL handshake requires 9 packets for a total of 12 packets.

(4) http: port 80; https: port 443.

(5) HTTPS is an HTTP protocol built on SSL/TLS, which consumes more server resources.

4. Https encryption process

A combination of symmetric encryption and asymmetric encryption is used to protect the security of communication between the browser and the server.

Approximate steps:
(1) The client requests the URL
(2) The server returns the certificate public key
(3) The client verifies the validity of the public key, and if it is valid, generates an encrypted random value and sends the encrypted key to the server
(4) The server uses the private key to decrypt, uses the key to encrypt the content to be sent, and sends it to the client.
(5) The client uses the key to decrypt the information.

5. The difference between TCP and UDP

(1) TCP: connection-oriented: a connection needs to be established before sending data

UDP: connectionless oriented: no connection is required before sending data

(2) TCP: byte stream oriented; UDP: datagram oriented

(3) TCP: Ensure data accuracy; UDP: Packets may be lost and one message is delivered to the IP layer at a time.

(4) TCP: data order guaranteed; UDP: not guaranteed

6. TCP three-way handshake and four-way wave

(1) Three-way handshake

SYN: Initialize connection establishment

ACK: Helps acknowledge received SYN messages

SYN-ACK: local SYN message and ACK message, return confirmation

Why not twice?

In order to achieve reliable data transmission, both communication parties of the TCP protocol must maintain a sequence number to identify which of the sent data packets have been received by the other party. The three-way handshake process is a necessary step for both communicating parties to inform each other of the starting value of the sequence number and confirm that the other party has received the starting value of the sequence number.

If there are only two handshakes, at most only the starting sequence number of the connection initiator can be confirmed, and the sequence number selected by the other party cannot be confirmed.

(2) Wave four times

Once, the client wants to terminate and sends FIN,

Second time, the server returns an ACK message, and the client enters the second waiting period.

Three times, the server returns FIN to close,

Four times, the client will change from the FIN_WAIT_2 state to the TIME_WAIT state. Clients in the TIME_WAIT state are allowed to resend ACKs to the server in order to prevent information loss.

7. Why is TCP reliable transmission (Computer Network Book p213-216)

Timeout retransmission, group confirmation,

(1) The data transmitted through the TCP connection is error-free, not lost, not repeated, and arrives in order.

(2) The sequence number in the TCP message header enables TCP data to arrive in order.

(3) The confirmation sequence number in the message header can ensure no packet loss, cumulative confirmation and timeout retransmission mechanism.

(4) TCP has flow control and congestion control mechanisms.

Explain yourself:

An error may occur before receiving the first packet confirmation. After a period of time, no confirmation is received. This time is set by setting a timeout timer every time a packet is sent, retransmitting if it exceeds, and canceling the timer if it does not exceed. After sending a packet, a copy needs to be saved and deleted when confirmation is received. Secondly, both packet sending and confirmation packets need to be numbered to ensure no errors.

When retransmitting, the duplicates sent before and now will be discarded and retransmitted to confirm.

TCP uses the sending window of the continuous ARQ protocol to move the sending window forward one bit after receiving the confirmation of a packet for the next transmission.

8. New features of HTTP2.0

(1) Add binary framing, headers frame, and data frame

(2) Compress headers and cache the same request headers

(3) Multiplexing, any number of bidirectional data streams

(4) Request priority

(5) Server prompts

9. The process after entering the url

(1) Domain name resolution

(2) TCP establishes connection

(3) http sends request

(4) Server response data

2. Continuously updating...

If there are mistakes, please correct me! ! !

Guess you like

Origin blog.csdn.net/qq_46269365/article/details/121007195