Network Protocols and Web Interfaces (PART 1)

HTTPProtocol evolution

The HTTP protocol is the foundation of the Internet.

HTTP / 0.9

In 1991, HTTP defined the core of the protocol in the very first version 0.9. Such as:

  • The basic structure of client and server is determined.
  • Use domain name /IP plus port number to determine the destination address;
  • A newline character is used as the basic separator.

It’s very simple, like:

GET /target.html
Copy the code
  • Request body is not supported;
  • Not supported exceptGETOther than methods;
  • Headers are not supported;
  • No explicit specification of a version number (no version number in the request);
  • The entire request is one line (The One-line Protocol).

Practice tool Telnet.

#Step 1: Shortcut keys evoke Windows command Window (1)
win + r
#Step 2: Shortcut keys evoke Windows Command Window (2)
cmd
#Step 3: Establish a connection using Telnet
telnet www.google.com 80
#Step 4: Send the request after the connection is successful
GET /
Copy the code

HTTP / 1.0

In 1996, HTTP 1.0 was stable and mature, and is the lowest version of the HTTP protocol widely supported by browsers today.

  • A return code was introduced;
  • The introduction of theheader;
  • The introduction of multi-character sets;
  • Support for multi-line requests.
  • Method supportsGET,HEAD,POST.
#A multi-line HTTP/1.0 request: request.txtGET/HTTP/1.0 user-agent: Mozilla/1.22 (compatible; MSIE 2.0; Windows 3.1) Accept: text/HTMLCopy the code

The blank line at the end of the code above is required: the protocol dictates that an extra newline carriage return must be added after the HTTP header ends for both requests and responses.

Changing the USER-Agent (UA) header can simulate different browsers.

Practice tool Netcat.

#Send the request using Netcat
netcat www.google.com 80 < ~/path to request.txt
Copy the code

HTTP / 1.1

The most widely used HTTP protocol.

In 1999, a number of features were added to improve transmission efficiency (RFC2616) :

  • HTTPA long connection(Connection: Keep-Alive), open it onceTCPConnection, which can be reused for several consecutive packets transmission;
  • Block transfer encoding(Transfer-Encoding: chunked), the response message will be transmitted by several blocks in batches.The end of the transfer is indicated by a block of length 0 and a blank line. Or after zero, add some extra informationTrailer; ,
  • A more holistic approach;
  • More comprehensive return codes;
  • Support for specified client caching policies;
  • rightcontent negotiation(Requested by the clientAcceptTo tell the server what type of content it can accept.
#An HTTP/1.1 long connection request: request.txtGET/HTTP/1.1 Host: www.google.com user-agent: Mozilla/1.22 (compatible; MSIE 2.0; Windows 3.1) Connection: keep-alive Accept: text/ HTMLCopy the code

HTTP/2

While maintaining compatibility, it contains the following important improvements:

  • A mechanism was designed to allow clients to choose which to useHTTPVersion;
  • HTTPCompression of the head;
  • Multiplexing, a method that allows clients to simultaneously transmit multiple sets of request responses in a single connection;
  • server-sidepushMechanism.

HTTP/3

Around the transmission efficiency of this protocol core to do further improvement.

Leak fill a vacancy

  1. Manually enable Telnet in Windows 10

    Win10 Telnet is not an internal or external command

Learning materials

  1. A systematic introduction to HTTP tutorial
  2. OSI 7 Layer Model of Network [EN]
  3. Location of Network Protocols in OSI layer 7 Model [EN]
  4. RFC documentation: HTTP 1.0[en]
  5. RFC Documentation: HTTP 1.1[en]
  6. RFC Documentation: HTTP 2.0[en]
  7. 9 major improvements to HTTP 1.0 to 1.1 [EN]
  8. HTTP/2 System Introduction [EN]

The resources

  1. Yesterday, Today, and Tomorrow: The evolution of the HTTP protocol