This is the 10th day of my participation in the August More text Challenge. For details, see: August More Text Challenge

Life is short. Let’s learn Python

This section describes the HTTP versions

HTTP protocol is the cornerstone of the Internet and server technology. The evolution of HTTP protocol also reflects the rapid development of Internet technology. These two days, in the preparation of a technology sharing process about the HTTP1.1 protocol features, by the way to understand the characteristics of the next VERSION of the HTTP protocol, here to make a simple summary.

The HTTP protocol has evolved into three versions. The first HTTP protocol was created in March 1989.

The HTTP 0.9

HTTP 0.9 is the first version of the HTTP protocol and is obsolete.

It is extremely simple, allows clients to only send GET requests, and does not support request headers.

HTTP 0.9 supports only one type of content, that is, plain text, because there is no protocol header. However, web pages can still be formatted in HTML, and images cannot be inserted.

HTTP 0.9 is typically stateless, with each transaction being processed independently and the connection being released at the end of the transaction.

An HTTP 0.9 transfer first establishes a TCP connection from the client to the Web server. The client initiates a request, the Web server returns the page contents, and the connection is closed. If the requested page does not exist, no error code is returned.

The HTTP 1.0

The second version of THE HTTP protocol, the first to specify a version number in communications, is still widely used today. The following major features have been added over HTTP 0.9:

  • Request and response support header fields
  • The response object starts with a response status line
  • Response objects are not limited to hypertext
  • The client can submit data to the Web server through the POST method. The GET, HEAD, and POST methods are supported
  • Supports long connections (but still uses short connections by default), caching mechanism, and identity authentication

The HTTP 1.1

The third version of the HTTP protocol, HTTP 1.1, is by far the most widely used. HTTP 1.1 is the current mainstream VERSION of the HTTP protocol.

HTTP 1.1 introduced a number of key performance optimizations: Keepalive connections, chunked encoded transfers, byte range requests, request pipelinings, etc

  • Persistent connections allow AN HTTP device to keepa TCP Connection open after a transaction has completed, reusing the current Connection for future HTTP requests until the client or server decides to close it. Using persistent connections in HTTP1.0 requires adding the request header Connection: keep-alive, while inAll HTTP 1.1 connections are persistent by defaultUnless otherwise specified (HTTP request header with Connection: close)

  • Chunked is a code that blocks entities and marks the length of each block until a length of 0 indicates the end of the transmission. This is especially useful when the entity length is unknown (such as data generated dynamically by a database).

  • Byte range requests HTTP1.1 supports sending part of the content. For example, when a client already has a portion of the content, it can request only a portion from the server to save bandwidth. This is done by introducing the range header field in the request message, which allows only a part of the resource to be requested. In the response message, the content-range header field declares the offset and length of the returned object. Response code 206 (Partial Content) if the server returns the contents of the scope requested by the object accordingly.

  • Pipelining

In addition, HTTP 1.1 has added the following features:

  • Both request and response messages should support the Host header field. HTTP1.0 assumes that each server is bound to a unique IP address, so the URL in the request message does not pass the hostname. However, with the development of virtual hosting technology, there can be multiple homed Web Servers on a physical server, and they share an IP address. Therefore, the introduction of the Host header is necessary.
  • The OPTIONS,PUT, DELETE, TRACE, and CONNECT methods are added to HTTP1.1
  • HTTP/1.1 adds some new cache features over and above 1.0, introducing entity tags, commonly known as e-tags, and a more powerful cache-control header.

The HTTP 2.0

HTTP 2.0 is the next generation of HTTP protocol, currently very few applications. The main features are:

In order to solve the problem of low utilization of 1.1 version, HTTP/2.0 version is proposed. Add duplex mode, that is, not only the client can send multiple requests at the same time, the server can also process multiple requests at the same time, to solve the queue head problem (HTTP2.0 uses multiplexing technology, the same connection can concurrently process multiple requests, and the number of concurrent requests is several orders of magnitude greater than HTTP1.1).

HTTP requests and responses in the status line and request/response headers are some of the information field, and no real data, so all of the information field in version 2.0 set up a table, for each field in the table index, the client and server to use the table together, between them, taking the index number to represent the information field, In this way, the repeated and tedious fields of the old 1.0 version are avoided and transmitted in a compressed way to improve utilization.

  • The best thing about HTTP 2.0 is that it doesn’t change the semantics of HTTP. The core concepts of HTTP methods, status codes, URIs, header fields, etc., are the same as they were before, but it is committed to breaking the performance limits of the previous generation of standards, improving transmission performance, and achieving low latency and high throughput. It is called 2.0 because of the new binary frame layer. At the binary frame splitting level, HTTP 2.0 will split all the transmitted information into smaller messages and frames and encode them in binary format. The Headers of http1.x will be encapsulated in a Headers frame and our request body will be encapsulated in a Data frame.HTTP 2.0 communication is all done over a single connection, which can host any number of two-way data streams. Accordingly, each data stream is sent as a message, which consists of one or more frames that can be sent out of order and then reassembled according to the stream identifier at the head of each frame.
  • Header compression When a client requests many resources from the same server, such as images from the same web page, there will be a large number of requests that look almost identical, which requires compression techniques to deal with this almost identical information.
  • Reset at any time One disadvantage of HTTP1.1 is that you can’t easily stop HTTP messages at any time when they have a certain length of data transfer, and breaking TCP connections is expensive. Using HTTP2’s RST_STREAM will make it easy to stop a message transfer and start new messages, improving bandwidth usage without interrupting the connection.
  • Server Push: When the client requests a resource X, the Server determines that the client may need resource Z, and pushes the resource Z to the client without asking the client in advance. After receiving the resource, the client can cache it for later use.
  • Priorities and Dependencies Each stream has its own priority, indicating which stream is the most important, the client specifies which stream is the most important, and there are dependencies so that one stream can depend on another. Priorities can change dynamically at run time, telling the browser which images are most important as the user scrolls through the page, and you can filter through a set of streams to suddenly capture the key streams.

conclusion

The article was first published in the wechat public account program Yuan Xiaozhuang, synchronized with nuggets.

Please explain where it came from. If you pass by, please put out your cute little finger and click like before you go (╹▽╹)