jinzhe

jinzhe

github
email

History of HTTP

HTTP is an application layer communication protocol based on TCP/IP, used to define communication rules between clients and servers.

http/0.9 (1991)#

The first recorded version of HTTP was introduced in 1991 as http/0.9, which is the simplest protocol ever.

  • No request headers
  • Only supports the GET method
  • Can only return HTML
GET /index.html

The server may return the following information

(res body)
(connection closed)

http/1.0 (1996)#

  • Supports request headers and response headers (including status codes, caching, authorization, character sets, etc.)
  • Additionally supports the HEAD and POST methods
  • Supports more response formats such as video, text, images, etc.

Warning

One of the main drawbacks of http/1.0 is that each connection cannot have multiple requests. For each request, a new connection must be established, resulting in performance waste due to the three-way handshake.

GET /index.html HTTP/1.0
Host: jinzhe.cc
Accept: */*

The server may return the following information

HTTP/1.0 200 OK 
Content-Type: text/plain
Server: Apache 0.84

(res body)
(connection closed)

http/1.1 (1999)#

  • Added PUT, PATCH, OPTIONS, DELETE
  • Added the Connection request header, allowing clients and servers to specify connection options.
  • Pipelining, clients can send multiple requests to the server on the same connection without waiting for the server's response, and the server must send responses in the order the requests were received. The client must use Content-Length to identify the end position.
  • Chunked transfer, when the server cannot determine the Content-Length, it will transfer data in chunks and add Content-Length to each chunk. The server includes the header Transfer-Encoding: chunked.

Warning

Content-Length does not completely solve the problem of persistent connections. If the data is dynamic and the server cannot determine the content length, the client will not know when the data ends.
Head-of-line blocking

SPDY (2009)#

  • Multiplexing
  • Compression
  • Prioritization
  • Security

The emergence of SPDY is not to replace HTTP, but to modify it before sending the request. It started to become the de facto standard, and most browsers began to implement it. By 2015, Google did not want to have two competing standards, so it decided to merge SPDY into HTTP/2.0 and deprecate SPDY.

http/2.0 (2015)#

HTTP/2 is designed for low-latency content transfer.

  • Binary, each HTTP/2 request and response is assigned a unique stream ID, and a stream is a collection of frames, each frame contains information such as frame type, stream ID, frame length, etc.
  • Multiplexing, all requests and responses for a connection are completed on the same TCP connection. The client sends asynchronously, and the server responds asynchronously, identified by stream ID.
  • HPACK header compression, using Huffman encoding.
  • Server push. Resources are pushed to the client without the client requesting them.
  • Request prioritization, the priority of a stream can be changed.
  • Security, although HTTP/2 does not require encryption by specification, it has become mandatory by default.

Three-Way Handshake#

Mermaid Loading...
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.