Skip to main content

8. HTTP Message Exchanges

HTTP/2 is intended to be as compatible as possible with current uses of HTTP. This means that the existing semantics of HTTP remain unchanged.

8.1 HTTP Request/Response Exchange

An HTTP request/response exchange consists of:

  1. HEADERS frame (with END_HEADERS flag)
  2. Zero or more CONTINUATION frames (if needed)
  3. Zero or more DATA frames
  4. Optional trailing HEADERS frame

HTTP Request

A complete HTTP request consists of:

  • A single HEADERS frame with END_HEADERS flag
  • Followed by zero or more DATA frames
  • Followed optionally by one HEADERS frame for trailers

HTTP Response

An HTTP response consists of:

  • A single HEADERS frame with END_HEADERS flag
  • Followed by zero or more DATA frames
  • Followed optionally by one HEADERS frame for trailers

8.2 Server Push

HTTP/2 allows a server to pre-emptively send responses to a client in association with a previous client-initiated request.

Server Push Flow:

  1. Server sends PUSH_PROMISE frame
  2. Server sends HEADERS + DATA frames on promised stream
  3. Client can cancel push via RST_STREAM

8.3 The CONNECT Method

The CONNECT method is used to establish a tunnel through an HTTP intermediary.