It goes without saying how important HTTP is. It’s almost something you have to understand. Start writing the summary! 😀

Basic Concepts of HTTP

What is HTTP?

HyperText Transfer Protocol (HTTP)

Hypertext refers to data such as text, pictures, videos, and hyperlinks. By contrast, HTML is the most common form of hypertext.

To transmit means to transmit between two points. This means that they can be transmitted to each other, indicating that HTTP is a two-way protocol.

Agreement is the agreement and norm of a kind of thing.

The bottom line is that HTTP is a convention and a specification for transferring text, pictures, video, and hyperlinks between two points in the computer world.

Common HTTP status code

There are five types of HTTP status codes:

meaning Common status code
1XX Is a temporary response that indicates that the request has been received, but that processing needs to continue
2XX Success. Indicates that the request was received by the server 200, 204, 206
3XX Redirection. The location of the resource has changed, requiring the client to resend the request. Follow-up Request Address this time the responseLocationIn the instructions 301, 302, 304
4XX Client error. The client sent an error that the server could not handle 400, 403, 404
5XX Server error. Indicates an error occurred during internal processing by the server 500, 501, 502, 503
  • 2XX

[200 OK] : This is what we want to see, indicating that the server successfully processed the client’s request.

[204 No Content] : This also indicates success. The server successfully processed the client request but did not return any Content.

[206 Partial Content] : Indicates that the server successfully processed some client requests. Can be used for HTTP block download and breakpoint continuation.

  • 3XX

[301 Multiple Choices] : Permanent redirection. Indicates that the requested resource has been permanently moved to a new location and requires a new URL to request it.

[302 Found] : Temporary redirection. Indicates that the requested resource is still available, but temporarily needs another URL to request it. (1) Moved.

[304 Not Modified] : Indicates that the resource is Not Modified. And there is no jump meaning, redirection oneself already cached cached files. This means that the data is already available and there is no need to request it.

  • 4XX

[400 Bad Request] : An obvious client error. The server cannot or will not process the Request.

[403 Forbidden] : The server cannot access the resource. There’s nothing wrong with your client, the server just won’t let you access it.

[404 Not Found] : This error is also common. Indicates that the requested resource was not found on the server.

  • 5XX

[500 Internal Server Error] : The Server sends an Internal Error.

[501 Not Implemented]: The server does Not support the functionality required for the current request. Similar to “under development, stay tuned.”

[502 Bad Gateway] : When a server working as a Gateway or proxy tries to execute a request, an invalid response is received from the upstream server.

[503 Service Unavailable] : Indicates that the current server is under maintenance or is overloaded and cannot process the current request. I’m too busy to talk to you.

Common HTTP Fields

Host: indicates the domain name and port number of the server. If it is the default port number, it can be omitted. (example: Host: www.baidu.com)

Content-length: indicates the Length of the message body. (Example content-length: 348)

Content-type: indicates the media Type of the object in the entity body. When the server responds, tell the client what format it is in this time. (case the content-type: text/HTML; Charset = utf-8)

Connection: indicates whether the Connection between the client and the server is maintained. (example Connection: keep-alive)

Content-encoding: specifies the compression method of the data returned by the server. (example content-encoding: gzip)

The characteristics of HTTP

Advantages and disadvantages of HTTP

The advantages of HTTP in particular are simplicity and flexibility, extensibility, widespread use, cross-platform, stateless, and plaintext transport.

But statelessness and plaintext transmission are both advantages and disadvantages.

Because of statelessness, the service does not have a “memory” capability, which does reduce the burden on the server, freeing up more CPU and memory for other uses. But frequently asking for identity information can be cumbersome when performing related operations such as “add to cart.”

There is also a way to solve this phenomenon, is to use Cookie technology, the use of Cookie technology to save the state.

For the plaintext transmission is both advantages and disadvantages, in our debugging time is really very convenient. But that means there is no privacy.

So one of the more serious disadvantages of HTTP is that it’s insecure

HTTP performance

(This refers to HTTP/1.1 performance)

HTTP is based on TCP.

HTTP/1.1 uses the persistent connection mode of communication, that is, persistent connections. It reduces the number of repetitions and overhead of TCP connections.

Because the long connection is used, piping is also possible. This means that requests can be sent multiple times within the same TCP connection, and the next request can be sent without waiting for it to come back.

In this way, the head block will also occur. This means that when the sent request is blocked for some reason, all subsequent requests remain in the queue. This is called blocked.

HTTP and HTTPS

Differences between HTTP and HTTPS

  • HTTPS solves the security defect of HTTP. HTTPS is SSL/TLS(Secure Sockets Layer/Transport Layer Security protocol) between TCP and HTTP

  • HTTP can transmit data after the TCP three-way handshake. In HTTPS, after the TCP three-way handshake, the SSL/TLS handshake is required for data transmission.

  • The HTTP port number is 80, and the HTTPS port number is 443

So how does HTTPS address the shortcomings of HTTP?

In order to ensure the confidentiality of information and prevent the risk of eavesdropping, hybrid encryption is adopted. HTTPS uses a hybrid encryption method that combines symmetric encryption and asymmetric encryption.

Abstract algorithm is adopted to ensure data integrity.

To address the risk of impersonation, digital certificates have also been added.

The evolution of the HTTP

HTTP/1.1 improvements over HTTP/1.0:

  • useTCPLong link way to improveHTTPDefect of short connection
  • Pipelining can be supported, reducing overall response time.

However, HTTP/1.1 is not secure, and there are instances of queue blocking, such as sending header sections without compression, and other performance impacts.

HTTP/2 improvements over HTTP/1.1

  • HTTP/2Is in theHTTPSSo the safety problem is guaranteed
  • Head compression,HTTP/2The headers are compressed to eliminate duplication
  • The binary format is adopted. Don’t likeHTTP / 1.1Is a plain text message
  • Multiplexing means that multiple requests can go through oneTCPTo complete the
  • Server push. Indicates that the server can pushHTMLThere is no need to wait for the client to parse the response before sending the request. Server push, the client also has the right to accept or not to receive.

It solves a lot of performance problems, but it still has some drawbacks, such as:

  • multipleHTTPRequest reuse in aTCPConnected to the inside, the lowerTCPThe protocol doesn’t know how manyHTTPrequest
  • If packet loss occurs, the TCP retransmission mechanism is triggered

So in HTTP3, instead of using TCP, use A UDP-based QUIC (Fast UDP Network connection), so that there are no more TCP round-trips to establish a stable connection; UDP doesn’t bother with this, which reduces the latency of requests, but it’s not as stable or as risky as losing packets.

Feel free to point out any inadequacies or inaccuracies in the comments section. 😄