rfc-9292

Binary Representation of HTTP Messages

M. Thomson, C. A. Wood
date2022-08 streamIETF areawit wghttpbis statusPROPOSED STANDARD pages16 canonicalhttps://www.rfc-editor.org/rfc/rfc9292 doi10.17487/RFC9292 errataview
This document defines a binary format for representing HTTP messages.

Extracted elements (27)

design-rationale §6

CONNECT and upgrade requests can technically be represented in this format but doing so serves no purpose, since those requests affect protocol behavior that this standalone format cannot replicate without additional mechanisms.

http

design-rationale §1

The format is explicitly not designed to capture all encoding details of specific HTTP versions (1.1, 2, 3); it conveys HTTP semantics only, making it unsuitable for applications that require an exact recording of wire-level encoding.

http

design-rationale §3.2

The Name Length field of a Field Line has a minimum value of 1, which is intentional: it allows the zero value of the Content Terminator to unambiguously signal end-of-section in indeterminate-length encoding without a separate sentinel byte.

http

design-rationale §3.5

The response status code is encoded as a variable-length integer (not a decimal string) because this format deals in HTTP semantics rather than in HTTP/1.1 syntax; the numeric value is what matters.

http

design-rationale §1

Two encoding modes are provided: known-length (all sections length-prefixed for efficient random access) and indeterminate-length (terminated sections for streaming use cases where lengths are not known at encoding time).

http

interoperability-note §3.6

Instances of the Cookie field are combined using a semicolon octet (0x3b) rather than a comma, matching the HTTP/2 behavior defined in Section 8.2.3 of HTTP/2.

http

interoperability-note §5.1

The Host header field is not replicated in the ':authority' control data field; Section 8.3.1 of HTTP/2 rules govern how the authority is derived, and the two must not be duplicated.

http

interoperability-note §6

This format does not preserve reason phrases from HTTP/1.1 responses, chunk extensions or transfer-encoding, header compression (HPACK/QPACK), or response framing that depends on the request method or status code (e.g., HEAD, 204, 304).

http

interoperability-note §6

Unlike HTTP/2 and HTTP/3 which use pseudo-header fields for control data, this format uses a fixed binary encoding for control data (method/target for requests, status code for responses).

http

normative-requirement §3.6 MUST

A recipient MUST treat a message that contains field values that would cause an HTTP/2 message to be malformed according to Section 8.2.1 of HTTP/2 as invalid.

http

normative-requirement §3.6 SHOULD

Connection-related header fields (HTTP Section 7.6.1) SHOULD be removed when constructing a binary message, though their presence does not make the message invalid.

http

normative-requirement §3.8 MUST

Decoders MUST treat missing truncated fields (i.e., trailing empty field sections or content that were omitted by the encoder) as equivalent to having been sent with the length field set to zero.

http

normative-requirement §4 MUST NOT

Invalid messages MUST NOT be processed further except to log an error and produce an error response.

http, security

normative-requirement §3.6 MUST

Messages are invalid if they contain fields named ':method', ':scheme', ':authority', ':path', or ':status'. Other extension-defined pseudo-fields MAY be included, and a Field Line containing pseudo-fields MUST precede all other Field Line values.

http

normative-requirement §3.8 MUST

Padding bytes MUST be zero-valued; non-zero padding bytes cause the message to be invalid. A processor MAY decide not to validate padding byte values.

http

normative-requirement §3.8 MUST

Truncation is only valid at the boundary of trailing empty field sections or empty content; a message truncated at any other point is invalid.

http

registry §7

IANA has added the 'message/bhttp' media type to the Media Types registry. Encoding is limited to '8bit' or 'binary'; it is intended for applications conveying HTTP semantics independently of a specific protocol version.

http, registry

security-consideration §8

Combining multiple field values (e.g., multiple Cookie field lines) into a single value may require commitment of additional resources and must be handled carefully, especially when translating to HTTP/1.1 or an API that expects a single value.

http, security

security-consideration §8

Strict parsing of the format with no tolerance for errors helps avoid security attacks. Implementations must also guard against resource exhaustion from large messages, particularly those with large numbers of header fields.

http, security

wire-format §3.1

A Known-Length Request consists of Framing Indicator (i)=0, Request Control Data, Known-Length Field Section (header), Known-Length Content, Known-Length Field Section (trailer), and Padding. A Known-Length Response uses Framing Indicator (i)=1 and replaces request control data with zero or more Known-Length Informational Responses followed by Final Response Control Data.

http

wire-format §3

All lengths and numeric values are encoded using the variable-length integer encoding from Section 16 of QUIC (RFC 9000). Integer values do not need to be encoded on the minimum number of bytes necessary, and the maximum encodable value is 2^62-1.

http, quic

wire-format §3.2

An Indeterminate-Length Request uses Framing Indicator (i)=2; field sections are terminated by a zero Content Terminator byte, and content is sent as one or more non-zero-length chunks each preceded by a Chunk Length variable-length integer, followed by a Content Terminator (i)=0. The indeterminate-length response uses Framing Indicator (i)=3.

http

wire-format §3.6

Each Field Line encodes Name Length (i, minimum 1), Name bytes, Value Length (i), and Value bytes. The Name Length minimum of 1 distinguishes field lines from the Content Terminator value of 0 in indeterminate-length sections.

http

wire-format §3.5

Final Response Control Data encodes the HTTP status code as a variable-length integer in the range 200–599, not as a length-prefixed decimal string as used in HTTP/1.1.

http

wire-format §3.5.1

Informational Response Control Data encodes a status code as a variable-length integer in the range 100–199 and is followed by a header section and another block of control data; this repeats until a final status code (200–599) is encountered.

http

wire-format §3.4

Request Control Data encodes Method, Scheme, Authority, and Path as an ordered sequence of length-prefixed byte strings. Where HTTP/2 would omit the ':authority' pseudo-header, a zero-length value is encoded instead.

http

wire-format §3.3

The binary message begins with a Framing Indicator, a single variable-length integer. Values 0–3 are defined: 0 = known-length request, 1 = known-length response, 2 = indeterminate-length request, 3 = indeterminate-length response. Any other value makes the message invalid.

http