RFC 7540: HTTP/2: Multiplexing over one connection

Summary

In May 2015, Mike Belshe, Roberto Peon and Martin Thomson specified the second version of HTTP in RFC 7540. HTTP/2 carries requests and responses as binary frames, interleaves many streams on one TCP connection and compresses headers with HPACK from RFC 7541. In June 2022 RFC 9113 replaced the document and dropped the original prioritisation scheme.

Many requests, one connection

The acknowledgements of the RFC list the contributors to SPDY separately, the predecessor developed at Google. HTTP/2 adopts its idea: one connection carries many concurrent requests instead of browsers having to open several TCP connections in parallel.

Every connection starts with a fixed 24-byte preface beginning with PRI * HTTP/2.0, followed by a SETTINGS frame. Over TLS, HTTP/2 is negotiated via ALPN with the identifier h2; the unencrypted variant is called h2c.

What did not work out

RFC 7540 described a dependency tree that let clients weight streams and make them depend on one another. In 2022 RFC 9113 states that this prioritisation scheme was not successful and recommends the simpler method from RFC 9218.

The switch from HTTP/1.1 to h2c via the Upgrade header was dropped as well. According to RFC 9113 it was never widely deployed; those using HTTP/2 without TLS speak it directly because both sides know in advance.

Ideas

  • Several requests share one TCP connection.
  • Binary frames replace the line-based text format of HTTP/1.1.
  • Frames from different streams are interleaved on the wire.
  • HPACK compresses recurring headers using a shared table.
  • Flow control applies per stream and to the whole connection.
  • Server push sends responses before the client asks for them.

Insights

  • Multiplexing removes waiting at the application layer but moves it into TCP: one lost packet stalls all streams.
  • A standard may contain features that do not prove themselves in practice, as long as a revision later clears them away.

Facts

  • RFC 7540 appeared in May 2015 as a Proposed Standard.
  • The client preface is 24 bytes long and starts with PRI * HTTP/2.0.
  • HPACK is specified in RFC 7541 and explicitly takes the CRIME attack on compressed headers into account.
  • RFC 9113 from June 2022 obsoletes RFC 7540 and RFC 8740.

References

Critique

  • The prioritisation scheme with dependency tree and weights was so complex that, by the assessment of its successor RFC 9113, it was not successful and was abandoned.

Remarks

  • The Rapid Reset attack disclosed in 2023 (CVE-2023-44487) used the rapid opening and cancelling of HTTP/2 streams for denial-of-service attacks.

Recommendations

  • Base new implementations on RFC 9113 rather than RFC 7540.
  • Set limits for concurrent streams and header size on the server deliberately.
  • Use curl --http2 -v to check whether a server negotiates h2 via ALPN.

Read the RFC at the RFC Editor

Search the Web Archive

Found a mistake or have something to add? Get in touch.