HTTP/1.1
-
Message delimitation is done via headers and content length.
-
Server and client use the
Content-Lengthfield to specify the exact size of the message body. This field tells the receiver how many bytes to read for the message. -
If the message size is not known in advance the server can use chunked transfer encoding, where data is split into variable-sized chunks and each chunk is prefixed with its size in hexadecimal.
-
In the header:
Content-Length: 1234
HTTP/2.0
-
Introduces stream multiplexing which means multiple messages can be sent at the same time using the same channel.
-
HTTP/2 uses frames to send data pieces. Each frame has a header with information about the data type and payload size.
-
Each message is associated with a Stream ID which allows multiple requests/responses to flow concurrently without interfering with each other.
-
Head of Line Blocking: In HTTP/2 requests/responses are split into frames and frames from different requests can be sent simultaneously.
HTTP/3.0 (QUIC)
-
HTTP/3 is an evolution of HTTP/2 built on the QUIC protocol, developed to improve performance and reduce latency.
-
QUIC replaces TCP with UDP to provide greater agility and uses frames to send data packets. Messages are split into frames and QUIC handles multiplexing of these messages.
-
HTTP/3 does not depend on the
Content-Lengthheader. Instead QUIC splits data into small packets and sends them independently, controlling flow via multiplexed data streams. -
Data Frames: QUIC uses data frames and each frame contains the payload size and a Stream ID that lets the server organize messages correctly.