Large HTTP/2 Header Frames
10/19/2024
In a previous post I explored how HTTP2 handles header frames in .NET 8. In this post I explore how it is planned to handle larger HTTP2 response header values.
Recap
RFC7540 describes the HTTP/2 protocol's related details.
In HTTP/2 a request-response pair is serialized in a stream.
A stream consists of message frames.
Frames have a type, frame header, a given size and corresponding data. Frames are associated with a given stream with the stream ID.
HTTP/2 requests start with HEADER frame. A header frame may be followed by CONTINUATION frames containing further headers.
The HTTP/2 request headers HPack encoded and split into HEADER and CONTINUATION frames.
In ASP.NET Core's Kestrel
HPackHeaderWriter
static class writes the headers.HPackHeaderWriter
iterates over the headers/trailers (except for the response status header which is written separately) using theHttp2FrameWriter
types.
Http2FrameWriter
creates the buffer which it passes as aSpan<byte>
to the header writer. The default size of the buffer is 16K, but it can be updated via Kestrel's option by setting theHttp2Limits
's MaxFrameSize property. Clients can also influence the frame size by sending a value in the SETTING frame.