RFC 8941
Structured Field Values for HTTP
RFC 8941 ๐ Structured Field Values for HTTP (Part 1 of 6)
Okay bestie, this one is an Internet Standards Track doc, so it's the real deal ๐
It came out in February 2021, written by M. Nottingham (Fastly) and P-H. Kamp (The Varnish Cache Project). The ISSN is 2070-1721. The title block doesn't list anything this RFC obsoletes or updates ๐ฆ
Abstract โจ
Okay so this document is all about a set of data types and the algorithms that go with them ๐ง The goal is to make it easier and safer to define and handle HTTP header and trailer fields, which people call "Structured Fields", "Structured Headers", or "Structured Trailers" ๐ It's meant for brand-new HTTP fields that want one shared syntax that's way stricter than the old-school field values we're used to ๐ฅ
Status of This Memo ๐ธ
This is an Internet Standards Track document.
This doc is a product of the Internet Engineering Task Force (IETF), and it totally represents the consensus of the IETF community ๐ซถ It got public review and was approved for publication by the Internet Engineering Steering Group (IESG). If you want more info on Internet Standards, check out Section 2 of RFC 7841 ๐
Info about the current status of this document, any errata, and how to give feedback on it lives at https://www.rfc-editor.org/info/rfc8941 ๐
Copyright Notice ๐
Copyright (c) 2021 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (https://trustee.ietf.org/license-info) as they stood on the publication date. Please read these docs carefully, because they spell out your rights and restrictions for this document ๐ Code Components pulled out of this document have to include the Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions, and they come without warranty, just like the Simplified BSD License says โญ
Table of Contents ๐ฆ
1. Introduction
1.1. Intentionally Strict Processing
1.2. Notational Conventions
2. Defining New Structured Fields
3. Structured Data Types
3.1. Lists
3.1.1. Inner Lists
3.1.2. Parameters
3.2. Dictionaries
3.3. Items
3.3.1. Integers
3.3.2. Decimals
3.3.3. Strings
3.3.4. Tokens
3.3.5. Byte Sequences
3.3.6. Booleans
4. Working with Structured Fields in HTTP
4.1. Serializing Structured Fields
4.1.1. Serializing a List
4.1.2. Serializing a Dictionary
4.1.3. Serializing an Item
4.1.4. Serializing an Integer
4.1.5. Serializing a Decimal
4.1.6. Serializing a String
4.1.7. Serializing a Token
4.1.8. Serializing a Byte Sequence
4.1.9. Serializing a Boolean
4.2. Parsing Structured Fields
4.2.1. Parsing a List
4.2.2. Parsing a Dictionary
4.2.3. Parsing an Item
4.2.4. Parsing an Integer or Decimal
4.2.5. Parsing a String
4.2.6. Parsing a Token
4.2.7. Parsing a Byte Sequence
4.2.8. Parsing a Boolean
5. IANA Considerations
6. Security Considerations
7. References
7.1. Normative References
7.2. Informative References
Appendix A. Frequently Asked Questions
A.1. Why Not JSON?
Appendix B. Implementation Notes
Acknowledgements
Authors' Addresses
1. Introduction ๐
Writing the syntax for a new HTTP header (or trailer) field is honestly a lot ๐ญ Even with the guidance in Section 8.3.1 of [RFC7231], there are so many decisions, and so many pitfalls, waiting for whoever is defining a new field ๐
Once a field exists, people usually end up writing their own bespoke parsers and serializers, because every field handles what looks like the same syntax just a little differently ๐
So this document introduces a shared set of data structures for defining new HTTP field values, which fixes that mess โจ It gives us a generic, abstract model, plus a concrete way to write that model into HTTP [RFC7230] header and trailer fields ๐
A field that's defined as a "Structured Header" or "Structured Trailer" uses the types from this spec to set its syntax and basic handling rules ๐ฆ (If a field can be either one, it's a "Structured Field.") That makes life easier for spec writers and for the people implementing them ๐ซถ
Future HTTP versions can also define different serializations of this same abstract model ๐ That means fields built on the model could get sent more efficiently without anyone having to redefine them ๐
Quick heads up: this doc is not trying to redefine the syntax of existing HTTP fields ๐ โโ๏ธ These mechanisms are only meant for fields that explicitly opt in.
Section 2 explains how to specify a Structured Field ๐
Section 3 defines a bunch of abstract data types that you can use in Structured Fields ๐ง
Those abstract types get serialized into, and parsed out of, HTTP field values using the algorithms in Section 4 โญ
1.1. Intentionally Strict Processing ๐ฅ
This spec is intentionally strict about parsing and serialization. It uses step-by-step algorithms, and the only error handling it defines is to fail the whole operation ๐
It's designed to get people implementing it faithfully, which means better interoperability ๐ An implementation that tries to be extra helpful by accepting sloppier input actually makes interop worse, because other implementations then feel pressure to build their own (probably slightly different) workarounds ๐
So yeah, strictness is a deliberate feature here ๐ It lets the producer catch and fix bad input early, and it avoids the interop and security problems that would otherwise pop up ๐ก๏ธ
Also, because it's this strict, if a field gets appended to by several parties (like intermediaries, or different components on the sender's side), a mistake from just one of them can make the whole field value fail to parse ๐ฌ
1.2. Notational Conventions ๐
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here ๐ซถ
This doc uses algorithms to describe parsing and serialization. It also uses Augmented Backus-Naur Form (ABNF) notation from [RFC5234] to show the expected syntax in HTTP header fields ๐ธ Along the way it uses the VCHAR, SP, DIGIT, ALPHA, and DQUOTE rules from [RFC5234], and the tchar and OWS rules from [RFC7230] ๐
When parsing HTTP fields, implementations MUST behave in a way that's indistinguishable from following the algorithms ๐ If the parsing algorithms and the ABNF ever disagree, the algorithms win ๐
For serialization, the ABNF shows what the wire format is expected to look like, and the algorithms define the recommended way to actually produce it โจ Implementations MAY vary from the specified behavior, as long as their output still gets handled correctly by the parsing algorithm in Section 4.2 ๐
2. Defining New Structured Fields โจ
okay so if you want to turn an HTTP field into a Structured Field, there's a little checklist ๐ authors need to:
- Normatively reference this specification. Recipients and generators of the field need to know that the requirements of this document are in effect. Basically, everyone has to know we're playing by these rules ๐
- Identify whether the field is a Structured Header (it can only be used in the header section, which is the common case ๐ง), a Structured Trailer (only in the trailer section), or a Structured Field (both).
- Specify the type of the field value: either List (Section 3.1), Dictionary (Section 3.2), or Item (Section 3.3).
- Define the semantics of the field value.
- Specify any additional constraints upon the field value, as well as the consequences when those constraints are violated.
Typically, this means a field definition will name the top-level type (List, Dictionary, or Item) and then define what types are allowed inside it and what constraints apply. For example, a header defined as a List might have all Integer members, or a mix of types. A header defined as an Item might allow only Strings, and additionally only strings beginning with the letter "Q", or strings in lowercase. Likewise, Inner Lists (Section 3.1.1) are only valid when a field definition explicitly allows them ๐ซถ
When parsing fails, the entire field is ignored (see Section 4.2). In most situations, violating field-specific constraints should have the same effect. So if a header is defined as an Item and required to be an Integer, but a String shows up, the field will be ignored by default ๐ If the field needs different error handling, that should be explicitly specified.
Both Items and Inner Lists allow parameters as an extensibility mechanism, which means values can be extended later to hold more information if needed ๐ To keep forward compatibility, field specifications are discouraged from making the presence of an unrecognized parameter an error condition.
To make sure this extensibility stays available in the future, and to encourage consumers to use a complete parser implementation, a field definition can specify that "grease" parameters be added by senders. A specification could say that all parameters matching a defined pattern are reserved for this use, and then encourage them to be sent on some portion of requests. This helps discourage recipients from writing a parser that doesn't account for Parameters. It's giving "don't you dare write a lazy parser" energy ๐ญ
Specifications that use Dictionaries can also allow for forward compatibility by requiring that the presence of unknown members, along with their values and types, be ignored. Later specifications can then add new members and specify constraints on them as appropriate ๐ฆ
An extension to a Structured Field can require that an entire field value be ignored by a recipient that understands the extension if the constraints it defines aren't met.
A field definition cannot relax the requirements of this specification, because doing so would stop generic software from handling the field. It can only add additional constraints. For example, it can limit the numeric range of Integers and Decimals, the format of Strings and Tokens, the types allowed in a Dictionary's values, or the number of Items in a List. Likewise, field definitions can only use this specification for the entire field value, not a portion of it ๐
This specification defines minimums for the length or number of various structures that implementations support. In most cases it does not specify maximum sizes, but authors should be aware that HTTP implementations do impose limits on the size of individual fields, the total number of fields, and/or the size of the entire header or trailer section. Plan accordingly, bestie ๐
Specifications can refer to a field name as a "structured header name", "structured trailer name", or "structured field name", as appropriate. Likewise, they can refer to its field value as a "structured header value", "structured trailer value", or "structured field value" as necessary. Field definitions are encouraged to use the ABNF rules beginning with "sf-" defined in this specification. Other rules in this specification are not intended to be used in field definitions โจ
For example, a fictitious Foo-Example header field might be specified as:
| 42. Foo-Example Header
|
| The Foo-Example HTTP header field conveys information about how
| much Foo the message has.
|
| Foo-Example is an Item Structured Header [RFC8941]. Its value
| MUST be an Integer (Section 3.3.1 of [RFC8941]). Its ABNF is:
|
| Foo-Example = sf-integer
|
| Its value indicates the amount of Foo in the message, and it MUST
| be between 0 and 10, inclusive; other values MUST cause the entire
| header field to be ignored.
|
| The following parameter is defined:
| * A parameter whose key is "foourl", and whose value is a String
| (Section 3.3.3 of [RFC8941]), conveying the Foo URL for the
| message. See below for processing requirements.
|
| "foourl" contains a URI-reference (Section 4.1 of [RFC3986]). If
| its value is not a valid URI-reference, the entire header field
| MUST be ignored. If its value is a relative reference
| (Section 4.2 of [RFC3986]), it MUST be resolved (Section 5 of
| [RFC3986]) before being used.
|
| For example:
|
| Foo-Example: 2; foourl="https://foo.example.com/"
3. Structured Data Types
This section defines the abstract types for Structured Fields. The ABNF provided represents the on-wire format in HTTP field values ๐ง
In summary:
- There are three top-level types an HTTP field can be defined as: Lists, Dictionaries, and Items.
- Lists and Dictionaries are containers. Their members can be Items or Inner Lists (which are themselves arrays of Items).
- Both Items and Inner Lists can be Parameterized with key/value pairs.
3.1. Lists
Lists are arrays of zero or more members. Each member can be an Item (Section 3.3) or an Inner List (Section 3.1.1), and both can be Parameterized (Section 3.1.2) ๐
The ABNF for Lists in HTTP fields is:
sf-list = list-member *( OWS "," OWS list-member )
list-member = sf-item / inner-list
Each member is separated by a comma and optional whitespace. For example, a field whose value is defined as a List of Tokens could look like:
Example-List: sugar, tea, rum
An empty List is denoted by not serializing the field at all. This implies that fields defined as Lists have a default empty value ๐ซ
Note that Lists can have their members split across multiple lines of the same header or trailer section, as per Section 3.2.2 of [RFC7230]. For example, the following are equivalent:
Example-List: sugar, tea, rum
and
Example-List: sugar, tea
Example-List: rum
However, individual members of a List cannot be safely split between lines. See Section 4.2 for details โ ๏ธ
Parsers MUST support Lists containing at least 1024 members. Field specifications can constrain the types and cardinality of individual List values as they require ๐ฅ
3.1.1. Inner Lists
An Inner List is an array of zero or more Items (Section 3.3). Both the individual Items and the Inner List itself can be Parameterized (Section 3.1.2) ๐ธ
The ABNF for Inner Lists is:
inner-list = "(" *SP [ sf-item *( 1*SP sf-item ) *SP ] ")"
parameters
Inner Lists are wrapped in parentheses, and their values are separated by one or more spaces. A field whose value is defined as a List of Inner Lists of Strings could look like:
Example-List: ("foo" "bar"), ("baz"), ("bat" "one"), ()
Note that the last member in this example is an empty Inner List ๐ฅบ
A header field whose value is defined as a List of Inner Lists, with Parameters at both levels, could look like:
Example-List: ("foo"; a=1;b=2);lvl=5, ("bar" "baz");lvl=1
Parsers MUST support Inner Lists containing at least 256 members. Field specifications can constrain the types and cardinality of individual Inner List members as they require ๐
3.1.2. Parameters
Parameters are an ordered map of key-value pairs associated with an Item (Section 3.3) or Inner List (Section 3.1.1). The keys are unique within the scope of the Parameters they occur in, and the values are bare items (meaning they can't be parameterized themselves; see Section 3.3) ๐
Implementations MUST provide access to Parameters both by index and by key. Specifications MAY use either means of accessing them ๐ง
The ABNF for Parameters is:
parameters = *( ";" *SP parameter )
parameter = param-key [ "=" param-value ]
param-key = key
key = ( lcalpha / "*" )
*( lcalpha / DIGIT / "_" / "-" / "." / "*" )
lcalpha = %x61-7A ; a-z
param-value = bare-item
Note that parameters are ordered as serialized, and parameter keys cannot contain uppercase letters. A parameter is separated from its Item or Inner List, and from other parameters, by a semicolon. For example:
Example-List: abc;a=1;b=2; cde_456, (ghi;jk=4 l);q="9";r=w
Parameters whose value is Boolean (see Section 3.3.6) true MUST omit that value when serialized. For example, the "a" parameter here is true, while the "b" parameter is false:
Example-Integer: 1; a; b=?0
Note that this requirement only applies to serialization. Parsers are still required to correctly handle the true value when it appears in a parameter ๐
Parsers MUST support at least 256 parameters on an Item or Inner List, and support parameter keys with at least 64 characters. Field specifications can constrain the order of individual parameters, as well as the types of their values, as required ๐ฆ
3.2. Dictionaries ๐
okay so Dictionaries are ordered maps of key-value pairs ๐๏ธ The keys are short textual strings, and the values are Items (Section 3.3) or arrays of Items. Both of those can be Parameterized (Section 3.1.2) โจ A Dictionary can have zero or more members, and every key has to be unique within the Dictionary it lives in ๐
Implementations MUST provide access to Dictionaries both by index and by key. Specifications MAY use either means of accessing the members. ๐ซถ
The ABNF for Dictionaries is:
sf-dictionary = dict-member *( OWS "," OWS dict-member )
dict-member = member-key ( parameters / ( "=" member-value ))
member-key = key
member-value = sf-item / inner-list
Members are ordered as they're serialized, and they're separated by a comma with optional whitespace ๐ Member keys can't contain uppercase characters ๐ Keys and values are split by "=", and there's no whitespace around it. Here's an example:
Example-Dict: en="Applepie", da=:w4ZibGV0w6ZydGU=:
Notice that the final "=" in this example is there because of the Byte Sequence. You can read more about that in Section 3.3.5 ๐
Members whose value is Boolean (see Section 3.3.6) true MUST omit that value when serialized ๐ธ In this example, both "b" and "c" are true:
Example-Dict: a=?0, b, c; foo=bar
This requirement only applies to serialization. Parsers are still required to correctly handle the true Boolean value when it shows up in Dictionary values ๐ง
Here's a Dictionary with a member whose value is an Inner List of Tokens:
Example-Dict: rating=1.5, feelings=(joy sadness)
And here's one with a mix of Items and Inner Lists, some of them with parameters ๐
Example-Dict: a=(1 2), b=3, c=4;aa=bb, d=(5 6);valid
Same as with Lists, an empty Dictionary is represented by leaving out the entire field. That means fields defined as Dictionaries have a default empty value ๐ฆ
Usually, a field specification will spell out what a Dictionary means. It does this by saying which types are allowed for each member, going by its key, and whether that member is required or optional ๐ Recipients MUST ignore members whose keys are undefined or unknown, unless the field's specification specifically disallows them. Basically, if you don't know the key, skip it, but only if the spec doesn't say otherwise ๐ โโ๏ธ
Dictionaries can have their members split across multiple lines of the same header or trailer section. For example, these two are equivalent โจ
Example-Dict: foo=1, bar=2
and
Example-Dict: foo=1
Example-Dict: bar=2
However, individual members of a Dictionary cannot be safely split between lines! Check Section 4.2 for the details ๐ญ
Parsers MUST support Dictionaries containing at least 1024 key/value pairs and keys with at least 64 characters. Field specifications can constrain the order of individual Dictionary members, and they can also require particular types for the values ๐
3.3. Items ๐
An Item can be an Integer (Section 3.3.1), a Decimal (Section 3.3.2), a String (Section 3.3.3), a Token (Section 3.3.4), a Byte Sequence (Section 3.3.5), or a Boolean (Section 3.3.6). It can also have associated parameters (Section 3.1.2) ๐
The ABNF for Items is:
sf-item = bare-item parameters
bare-item = sf-integer / sf-decimal / sf-string / sf-token
/ sf-binary / sf-boolean
For example, a header field defined as an Item that is an Integer might look like this:
Example-Integer: 5
Or with parameters:
Example-Integer: 5; foo=bar
3.3.1. Integers ๐ข
Integers range from -999,999,999,999,999 to 999,999,999,999,999 inclusive. That's up to fifteen digits, signed, and it's done this way for IEEE 754 compatibility [IEEE754] ๐งฎ
The ABNF for Integers is:
sf-integer = ["-"] 1*15DIGIT
For example:
Example-Integer: 42
Integers with more than 15 digits can be supported in a few ways. You could use a String (Section 3.3.3), a Byte Sequence (Section 3.3.5), or a parameter on an Integer that acts as a scaling factor ๐
It's possible to serialize Integers with leading zeros (e.g., "0002", "-01") and signed zero ("-0"), but these distinctions may not be preserved by implementations ๐คทโโ๏ธ
Commas in Integers are only used in this section's prose for readability. They're not valid in the wire format ๐
3.3.2. Decimals ๐ซ
Decimals are numbers with an integer part and a fractional part. The integer part has at most 12 digits, and the fractional part has at most three digits ๐
The ABNF for Decimals is:
sf-decimal = ["-"] 1*12DIGIT "." 1*3DIGIT
For example, a header whose value is defined as a Decimal could look like this:
Example-Decimal: 4.5
It's possible to serialize Decimals with leading zeros (e.g., "0002.5", "-01.334"), trailing zeros (e.g., "5.230", "-0.40"), and signed zero (e.g., "-0.0"). These distinctions may not be preserved by implementations, though ๐ซ
The serialization algorithm (Section 4.1.5) rounds input that has more than three digits of precision in the fractional part. If you want a different rounding strategy, the header definition should say so, and that rounding has to happen before serialization ๐ฐ
3.3.3. Strings ๐งต
Strings are zero or more printable ASCII [RFC0020] characters, meaning the range %x20 to %x7E. This excludes tabs, newlines, carriage returns, and so on ๐ซ
The ABNF for Strings is:
sf-string = DQUOTE *chr DQUOTE
chr = unescaped / escaped
unescaped = %x20-21 / %x23-5B / %x5D-7E
escaped = "\" ( DQUOTE / "\" )
Strings are wrapped in double quotes, and a backslash ("") is used to escape double quotes and backslashes. For example:
Example-String: "hello world"
Strings only use DQUOTE as a delimiter, so single quotes don't wrap Strings ๐ โโ๏ธ Also, only DQUOTE and "" can be escaped. Any other character after "" MUST cause parsing to fail ๐จ
Unicode isn't directly supported in Strings. It causes a bunch of interoperability problems, and with a few exceptions, field values don't need it anyway ๐
If a field value does need to carry non-ASCII content, use a Byte Sequence (Section 3.3.5) and specify a character encoding, preferably UTF-8 [STD63] ๐ซถ
Parsers MUST support Strings (after any decoding) with at least 1024 characters ๐ช
3.3.4. Tokens ๐ช
Tokens are short textual words. Their abstract model is identical to how they're written in the HTTP field value serialization โจ
The ABNF for Tokens is:
sf-token = ( ALPHA / "*" ) *( tchar / ":" / "/" )
For example:
Example-Token: foo123/456
Parsers MUST support Tokens with at least 512 characters ๐โโ๏ธ
Tokens allow the same characters as the "token" ABNF rule defined in [RFC7230]. The differences are that the first character has to be either ALPHA or "*", and ":" and "/" are also allowed in the characters that come after the first one ๐
3.3.5. Byte Sequences ๐ง
Byte Sequences can be carried in Structured Fields ๐ฆ
The ABNF for a Byte Sequence is:
sf-binary = ":" *(base64) ":"
base64 = ALPHA / DIGIT / "+" / "/" / "="
A Byte Sequence is wrapped in colons and encoded using base64 ([RFC4648], Section 4). For example:
Example-ByteSequence: :cHJldGVuZCB0aGlzIGlzIGJpbmFyeSBjb250ZW50Lg==:
Parsers MUST support Byte Sequences with at least 16384 octets after decoding ๐
3.3.6. Booleans โ
Boolean values can be carried in Structured Fields ๐
The ABNF for a Boolean is:
sf-boolean = "?" boolean
boolean = "0" / "1"
A Boolean starts with a "?" followed by a "1" for true or a "0" for false. For example:
Example-Boolean: ?1
In Dictionary (Section 3.2) and Parameter (Section 3.1.2) values, Boolean true is shown by leaving the value out entirely ๐ธ
4. Working with Structured Fields in HTTP โจ
This section explains how to serialize and parse Structured Fields in textual HTTP field values, and in other encodings that are compatible with them. One example is HTTP/2 [RFC7540] before compression with HPACK [RFC7541] ๐ฆ
4.1. Serializing Structured Fields ๐งฉ
Given a structure defined in this specification, you return an ASCII string that works as an HTTP field value ๐
- If the structure is a Dictionary or List and its value is empty (meaning it has no members), don't serialize the field at all. Leave out both the field-name and the field-value ๐
- If the structure is a List, the output_string is the result of running Serializing a List (Section 4.1.1) with the structure.
- Else, if the structure is a Dictionary, the output_string is the result of running Serializing a Dictionary (Section 4.1.2) with the structure.
- Else, if the structure is an Item, the output_string is the result of running Serializing an Item (Section 4.1.3) with the structure.
- Else, fail serialization. ๐
- Return output_string converted into an array of bytes, using ASCII encoding [RFC0020] ๐ซง
4.1.1. Serializing a List ๐
Given an array of (member_value, parameters) tuples as input_list, you return an ASCII string that works as an HTTP field value ๐
- Start with an empty output string ๐ซ
- For each (member_value, parameters) in input_list:
- If member_value is an array, append the result of running Serializing an Inner List (Section 4.1.1.1) with (member_value, parameters) to output.
- Otherwise, append the result of running Serializing an Item (Section 4.1.3) with (member_value, parameters) to output.
- If more member_values are left in input_list:
- Append "," to output.
- Append a single SP to output.
- Return output. โจ
4.1.1.1. Serializing an Inner List ๐ช
Given an array of (member_value, parameters) tuples as inner_list, and parameters as list_parameters, you return an ASCII string that works as an HTTP field value ๐ท
- Let output be the string "(". ๐
- For each (member_value, parameters) in inner_list:
- Append the result of running Serializing an Item (Section 4.1.3) with (member_value, parameters) to output.
- If more values are left in inner_list, append a single SP to output.
- Append ")" to output.
- Append the result of running Serializing Parameters (Section 4.1.1.2) with list_parameters to output.
- Return output. ๐ฆ
4.1.1.2. Serializing Parameters ๐ท๏ธ
Given an ordered Dictionary as input_parameters (where each member has a param_key and a param_value), you return an ASCII string that works as an HTTP field value ๐
- Start with an empty output string. ๐ซง
- For each param_key with a value of param_value in input_parameters:
- Append ";" to output.
- Append the result of running Serializing a Key (Section 4.1.1.3) with param_key to output.
- If param_value is not Boolean true:
- Append "=" to output.
- Append the result of running Serializing a bare Item (Section 4.1.3.1) with param_value to output.
- Return output. ๐
4.1.1.3. Serializing a Key ๐
Given a key as input_key, you return an ASCII string that works as an HTTP field value ๐๏ธ
- Convert input_key into a sequence of ASCII characters. If that conversion fails, fail serialization. ๐
- If input_key contains any characters that aren't lcalpha, DIGIT, "_", "-", ".", or "*", fail serialization. ๐ซ
- If the first character of input_key isn't lcalpha or "*", fail serialization. ๐ โโ๏ธ
- Start with an empty output string. ๐ซ
- Append input_key to output. ๐
- Return output. ๐
4.1.2. Serializing a Dictionary ๐
okay so this is the dictionary serializer, and it's basically the list one but with key-value energy ๐
You start with an ordered Dictionary called input_dictionary. Each member has a member_key and a tuple value of (member_value, parameters). You turn all of that into an ASCII string that's safe to use as an HTTP field value ๐ฆ
- Let
outputbe an empty string. - For each
member_keywith a value of(member_value, parameters)ininput_dictionary:- Append the result of running Serializing a Key (Section 4.1.1.3) with
member'smember_keytooutput. - If
member_valueis Boolean true:- Append the result of running Serializing Parameters (Section 4.1.1.2) with
parameterstooutput.
- Append the result of running Serializing Parameters (Section 4.1.1.2) with
- Otherwise:
- Append
"="tooutput. - If
member_valueis an array, append the result of running Serializing an Inner List (Section 4.1.1.1) with(member_value, parameters)tooutput. - Otherwise, append the result of running Serializing an Item (Section 4.1.3) with
(member_value, parameters)tooutput.
- Append
- If more members remain in
input_dictionary:- Append
","tooutput. - Append a single SP to
output.
- Append
- Append the result of running Serializing a Key (Section 4.1.1.3) with
- Return
output. ๐ธ
4.1.3. Serializing an Item โจ
this one takes an Item as bare_item and Parameters as item_parameters, and gives you back an ASCII string for an HTTP field value. it's giving "two pieces stuck together" ๐ง
- Let
outputbe an empty string. - Append the result of running Serializing a Bare Item (Section 4.1.3.1) with
bare_itemtooutput. - Append the result of running Serializing Parameters (Section 4.1.1.2) with
item_parameterstooutput. - Return
output.
4.1.3.1. Serializing a Bare Item ๐
so this is the type-checker moment ๐ you look at what kind of value input_item is and hand it off to the right serializer:
- If
input_itemis an Integer, return the result of running Serializing an Integer (Section 4.1.4) withinput_item. - If
input_itemis a Decimal, return the result of running Serializing a Decimal (Section 4.1.5) withinput_item. - If
input_itemis a String, return the result of running Serializing a String (Section 4.1.6) withinput_item. - If
input_itemis a Token, return the result of running Serializing a Token (Section 4.1.7) withinput_item. - If
input_itemis a Byte Sequence, return the result of running Serializing a Byte Sequence (Section 4.1.8) withinput_item. - If
input_itemis a Boolean, return the result of running Serializing a Boolean (Section 4.1.9) withinput_item. - Otherwise, fail serialization. ๐
4.1.4. Serializing an Integer ๐
given an Integer called input_integer, we make it into an ASCII string. no drama, just numbers ๐ข
- If
input_integeris not an integer in the range of-999,999,999,999,999to999,999,999,999,999inclusive, fail serialization. - Let
outputbe an empty string. - If
input_integeris less than (but not equal to)0, append"-"tooutput. - Append
input_integer's numeric value represented in base 10 using only decimal digits tooutput. - Return
output.
4.1.5. Serializing a Decimal ๐
decimals are a whole vibe ๐ we take a decimal number called input_decimal and make it an ASCII string, but we keep it tidy first.
- If
input_decimalis not a decimal number, fail serialization. - If
input_decimalhas more than three significant digits to the right of the decimal point, round it to three decimal places, rounding the final digit to the nearest value, or to the even value if it is equidistant. - If
input_decimalhas more than 12 significant digits to the left of the decimal point after rounding, fail serialization. - Let
outputbe an empty string. - If
input_decimalis less than (but not equal to)0, append"-"tooutput. - Append
input_decimal's integer component represented in base 10 (using only decimal digits) tooutput; if it is zero, append"0". - Append
"."tooutput. - If
input_decimal's fractional component is zero, append"0"tooutput. - Otherwise, append the significant digits of
input_decimal's fractional component represented in base 10 (using only decimal digits) tooutput. - Return
output.
4.1.6. Serializing a String ๐
this one is for a String called input_string. it has to be ASCII, and it gets wrapped in DQUOTE quote marks, so you know it's a string and not a whole mood ๐ซถ
- Convert
input_stringinto a sequence of ASCII characters; if conversion fails, fail serialization. - If
input_stringcontains characters in the range%x00-1for%x7f-ff(i.e., not in VCHAR or SP), fail serialization. - Let
outputbe the string DQUOTE. - For each character
charininput_string:- If
charis"\"or DQUOTE:- Append
"\"tooutput.
- Append
- Append
chartooutput.
- If
- Append DQUOTE to
output. - Return
output.
4.1.7. Serializing a Token ๐ฆ
Tokens are the cool, unquoted kids ๐ we take a Token called input_token and check it's the right shape before letting it through.
- Convert
input_tokeninto a sequence of ASCII characters; if conversion fails, fail serialization. - If the first character of
input_tokenis not ALPHA or"*", or the remaining portion contains a character not in tchar,":", or"/", fail serialization. - Let
outputbe an empty string. - Append
input_tokentooutput. - Return
output.
4.1.8. Serializing a Byte Sequence ๐ฌ
byte sequences get base64-encoded and wrapped in colons, like little bread slices around the good stuff ๐ฅช
- If
input_bytesis not a sequence of bytes, fail serialization. - Let
outputbe an empty string. - Append
":"tooutput. - Append the result of base64-encoding
input_bytesas per [RFC4648], Section 4, taking account of the requirements below. - Append
":"tooutput. - Return
output.
The encoded data is required to be padded with "=", as per [RFC4648], Section 3.2.
Likewise, encoded data SHOULD have pad bits set to zero, as per [RFC4648], Section 3.5, unless it is not possible to do so due to implementation constraints. ๐งผ
4.1.9. Serializing a Boolean ๐
last serializer of this bunch, and it's the simplest one ever ๐ฅน a Boolean called input_boolean turns into ?1 or ?0.
- If
input_booleanis not a boolean, fail serialization. - Let
outputbe an empty string. - Append
"?"tooutput. - If
input_booleanis true, append"1"tooutput. - If
input_booleanis false, append"0"tooutput. - Return
output.
4.2. Parsing Structured Fields ๐
okay bestie, now we're flipping it around and reading the strings back in ๐ this part is serious business, because there are a bunch of sneaky edge cases that can cause interoperability problems or even security problems ๐ญ so this section spells out the exact algorithm, and you do not skip steps.
Given an array of bytes as input_bytes that represent the chosen field's field-value (which is empty if that field is not present) and field_type (one of "dictionary", "list", or "item"), return the parsed header value.
- Convert
input_bytesinto an ASCII stringinput_string; if conversion fails, fail parsing. - Discard any leading SP characters from
input_string. - If
field_typeis"list", letoutputbe the result of running Parsing a List (Section 4.2.1) withinput_string. - If
field_typeis"dictionary", letoutputbe the result of running Parsing a Dictionary (Section 4.2.2) withinput_string. - If
field_typeis"item", letoutputbe the result of running Parsing an Item (Section 4.2.3) withinput_string. - Discard any leading SP characters from
input_string. - If
input_stringis not empty, fail parsing. - Otherwise, return
output.
When generating input_bytes, parsers MUST combine all field lines in the same section (header or trailer) that case-insensitively match the field name into one comma-separated field-value, as per [RFC7230], Section 3.2.2; this assures that the entire field value is processed correctly. ๐งฉ
For Lists and Dictionaries, this has the effect of correctly concatenating all of the field's lines, as long as individual members of the top-level data structure are not split across multiple header instances. The parsing algorithms for both types allow tab characters, since these might be used to combine field lines by some implementations. ๐ ๏ธ
Strings split across multiple field lines will have unpredictable results, because one or more commas (with optional whitespace) will become part of the string output by the parser. Since concatenation might be done by an upstream intermediary, the results are not under the control of the serializer or the parser, even when they are both under the control of the same party. ๐ตโ๐ซ
Tokens, Integers, Decimals, and Byte Sequences cannot be split across multiple field lines because the inserted commas will cause parsing to fail. ๐ซ
Parsers MAY fail when processing a field value spread across multiple field lines, when one of those lines does not parse as that field. For example, a parsing handling an Example-String field that's defined as an sf-string is allowed to fail when processing this field section:
Example-String: "foo
Example-String: bar"
If parsing fails -- including when calling another algorithm -- the entire field value MUST be ignored (i.e., treated as if the field were not present in the section). This is intentionally strict, to improve interoperability and safety, and specifications referencing this document are not allowed to loosen this requirement. ๐ โโ๏ธ
Note that this requirement does not apply to an implementation that is not parsing the field; for example, an intermediary is not required to strip a failing field from a message before forwarding it. ๐ซ
4.2.1. Parsing a List ๐งบ
Given an ASCII string as input_string, we return an array of (item_or_inner_list, parameters) tuples. input_string gets modified as we chew through it, so the parsed bit disappears ๐ฝ๏ธ
- Let
membersbe an empty array. - While
input_stringis not empty:- Append the result of running Parsing an Item or Inner List (Section 4.2.1.1) with
input_stringtomembers. - Discard any leading OWS characters from
input_string. - If
input_stringis empty, returnmembers. - Consume the first character of
input_string; if it is not",", fail parsing. - Discard any leading OWS characters from
input_string. - If
input_stringis empty, there is a trailing comma; fail parsing.
- Append the result of running Parsing an Item or Inner List (Section 4.2.1.1) with
- No structured data has been found; return
members(which is empty).
4.2.1.1. Parsing an Item or Inner List ๐
Given an ASCII string as input_string, we return the tuple (item_or_inner_list, parameters), where item_or_inner_list can be either a single bare item or an array of (bare_item, parameters) tuples. input_string is modified to remove the parsed value.
- If the first character of
input_stringis"(", return the result of running Parsing an Inner List (Section 4.2.1.2) withinput_string. - Return the result of running Parsing an Item (Section 4.2.3) with
input_string.
4.2.1.2. Parsing an Inner List ๐ท
Given an ASCII string as input_string, we return the tuple (inner_list, parameters), where inner_list is an array of (bare_item, parameters) tuples. input_string is modified to remove the parsed value.
- Consume the first character of
input_string; if it is not"(", fail parsing. - Let
inner_listbe an empty array. - While
input_stringis not empty:- Discard any leading SP characters from
input_string. - If the first character of
input_stringis")":
- Discard any leading SP characters from
- Consume the first character of input_string.
- Let parameters be the result of running Parsing Parameters (Section 4.2.3.2) with input_string.
- Return the tuple (inner_list, parameters).
- Let item be the result of running Parsing an Item (Section 4.2.3) with input_string.
- Append item to inner_list.
- If the first character of input_string is not SP or ")", fail parsing.
- The end of the Inner List was not found; fail parsing.
4.2.2. Parsing a Dictionary ๐ง
Given an ASCII string as input_string, return an ordered map whose values are (item_or_inner_list, parameters) tuples. input_string is modified to remove the parsed value.
- Let dictionary be an empty, ordered map.
- While input_string is not empty:
- Let this_key be the result of running Parsing a Key (Section 4.2.3.3) with input_string.
- If the first character of input_string is
"=":- Consume the first character of input_string.
- Let member be the result of running Parsing an Item or Inner List (Section 4.2.1.1) with input_string.
- Otherwise:
- Let value be Boolean true.
- Let parameters be the result of running Parsing Parameters (Section 4.2.3.2) with input_string.
- Let member be the tuple (value, parameters).
- If dictionary already contains a key this_key (comparing character for character), overwrite its value with member.
- Otherwise, append key this_key with value member to dictionary.
- Discard any leading OWS characters from input_string.
- If input_string is empty, return dictionary.
- Consume the first character of input_string; if it is not
",", fail parsing. - Discard any leading OWS characters from input_string.
- If input_string is empty, there is a trailing comma; fail parsing.
- No structured data has been found; return dictionary (which is empty).
Note that when duplicate Dictionary keys are encountered, all but the last instance are ignored.
4.2.3. Parsing an Item โจ
Given an ASCII string as input_string, return a (bare_item, parameters) tuple. input_string is modified to remove the parsed value.
- Let bare_item be the result of running Parsing a Bare Item (Section 4.2.3.1) with input_string.
- Let parameters be the result of running Parsing Parameters (Section 4.2.3.2) with input_string.
- Return the tuple (bare_item, parameters).
4.2.3.1. Parsing a Bare Item ๐
Given an ASCII string as input_string, return a bare Item. input_string is modified to remove the parsed value.
- If the first character of input_string is a
"-"or a DIGIT, return the result of running Parsing an Integer or Decimal (Section 4.2.4) with input_string. - If the first character of input_string is a DQUOTE, return the result of running Parsing a String (Section 4.2.5) with input_string.
- If the first character of input_string is an ALPHA or
"*", return the result of running Parsing a Token (Section 4.2.6) with input_string. - If the first character of input_string is
":", return the result of running Parsing a Byte Sequence (Section 4.2.7) with input_string. - If the first character of input_string is
"?", return the result of running Parsing a Boolean (Section 4.2.8) with input_string. - Otherwise, the item type is unrecognized; fail parsing.
4.2.3.2. Parsing Parameters ๐
Given an ASCII string as input_string, return an ordered map whose values are bare Items. input_string is modified to remove the parsed value.
- Let parameters be an empty, ordered map.
- While input_string is not empty:
- If the first character of input_string is not
";", exit the loop. - Consume the
";"character from the beginning of input_string. - Discard any leading SP characters from input_string.
- Let param_key be the result of running Parsing a Key (Section 4.2.3.3) with input_string.
- Let param_value be Boolean true.
- If the first character of input_string is
"=":- Consume the
"="character at the beginning of input_string. - Let param_value be the result of running Parsing a Bare Item (Section 4.2.3.1) with input_string.
- Consume the
- If parameters already contains a key param_key (comparing character for character), overwrite its value with param_value.
- Otherwise, append key param_key with value param_value to parameters.
- If the first character of input_string is not
- Return parameters.
Note that when duplicate parameter keys are encountered, all but the last instance are ignored.
4.2.3.3. Parsing a Key ๐
Given an ASCII string as input_string, return a key. input_string is modified to remove the parsed value.
- If the first character of input_string is not lcalpha or
"*", fail parsing. - Let output_string be an empty string.
- While input_string is not empty:
- If the first character of input_string is not one of lcalpha, DIGIT,
"_","-",".", or"*", return output_string. - Let char be the result of consuming the first character of input_string.
- Append char to output_string.
- If the first character of input_string is not one of lcalpha, DIGIT,
- Return output_string.
4.2.4. Parsing an Integer or Decimal ๐ธ
Given an ASCII string as input_string, return an Integer or Decimal. input_string is modified to remove the parsed value.
NOTE: This algorithm parses both Integers (Section 3.3.1) and Decimals (Section 3.3.2), and returns the corresponding structure.
- Let type be
"integer". - Let sign be 1.
- Let input_number be an empty string.
- If the first character of input_string is
"-", consume it and set sign to -1. - If input_string is empty, there is an empty integer; fail parsing.
- If the first character of input_string is not a DIGIT, fail parsing.
- While input_string is not empty:
- Let char be the result of consuming the first character of input_string.
- If char is a DIGIT, append it to input_number.
- Else, if type is
"integer"and char is".":- If input_number contains more than 12 characters, fail parsing.
- Otherwise, append char to input_number and set type to
"decimal".
- Otherwise, prepend char to input_string, and exit the loop.
- If type is
"integer"and input_number contains more than 15 characters, fail parsing. - If type is
"decimal"and input_number contains more than 16 characters, fail parsing.
- If type is
"integer":- Parse input_number as an integer and let output_number be the product of the result and sign.
- Otherwise:
- If the final character of input_number is
".", fail parsing. - If the number of characters after
"."in input_number is greater than three, fail parsing. - Parse input_number as a decimal number and let output_number be the product of the result and sign.
- If the final character of input_number is
- Return output_number.
4.2.5. Parsing a String ๐ง
Given an ASCII string as input_string, return an unquoted String. input_string is modified to remove the parsed value.
- Let output_string be an empty string.
- If the first character of input_string is not DQUOTE, fail parsing.
- Discard the first character of input_string.
- While input_string is not empty:
- Let char be the result of consuming the first character of input_string.
- If char is a backslash (
"\"):- If input_string is now empty, fail parsing.
- Let next_char be the result of consuming the first character of input_string.
- If next_char is not DQUOTE or
"\", fail parsing. - Append next_char to output_string.
- Else, if char is DQUOTE, return output_string.
- Else, if char is in the range
%x00-1for%x7f-ff(i.e., it is not in VCHAR or SP), fail parsing. - Else, append char to output_string.
- Reached the end of input_string without finding a closing DQUOTE; fail parsing.
4.2.6. Parsing a Token ๐ฆ
Given an ASCII string as input_string, return a Token. input_string is modified to remove the parsed value.
- If the first character of input_string is not ALPHA or
"*", fail parsing. - Let output_string be an empty string.
- While input_string is not empty:
- If the first character of input_string is not in tchar,
":", or"/", return output_string. - Let char be the result of consuming the first character of input_string.
- Append char to output_string.
- If the first character of input_string is not in tchar,
- Return output_string.
4.2.7. Parsing a Byte Sequence ๐
Given an ASCII string as input_string, return a Byte Sequence. input_string is modified to remove the parsed value.
- If the first character of input_string is not
":", fail parsing. - Discard the first character of input_string.
- If there is not a
":"character before the end of input_string, fail parsing. - Let b64_content be the result of consuming content of input_string up to but not including the first instance of the character
":". - Consume the
":"character at the beginning of input_string. - If b64_content contains a character not included in ALPHA, DIGIT,
"+","/", and"=", fail parsing. - Let binary_content be the result of base64-decoding [RFC4648] b64_content, synthesizing padding if necessary (note the requirements about recipient behavior below). If base64 decoding fails, parsing fails.
- Return binary_content.
Because some implementations of base64 do not allow rejection of encoded data that is not properly "=" padded (see [RFC4648], Section 3.2), parsers SHOULD NOT fail when "=" padding is not present, unless they cannot be configured to do so.
Because some implementations of base64 do not allow rejection of encoded data that has non-zero pad bits (see [RFC4648], Section 3.5), parsers SHOULD NOT fail when non-zero pad bits are present, unless they cannot be configured to do so.
This specification does not relax the requirements in [RFC4648], Sections 3.1 and 3.3; therefore, parsers MUST fail on characters outside the base64 alphabet and on line feeds in encoded data.
4.2.8. Parsing a Boolean โ
Given an ASCII string as input_string, return a Boolean. input_string is modified to remove the parsed value.
- If the first character of input_string is not
"?", fail parsing. - Discard the first character of input_string.
- If the first character of input_string matches
"1", discard the first character, and return true. - If the first character of input_string matches
"0", discard the first character, and return false. - No value has matched; fail parsing.
5. IANA Considerations ๐
This document has no IANA actions.
6. Security Considerations ๐
okay bestie, security time ๐ญ most of the types in Structured Fields don't have a size limit, so an extremely large field could be an attack vector (like for resource consumption ๐). that's why most HTTP implementations cap the size of individual fields AND the overall header or trailer section size to mitigate it ๐ก๏ธ
also, anyone who can inject new HTTP fields can change what a Structured Field means ๐ sometimes that makes parsing fail, but there's no way to reliably make it fail in every single case. not me being dramatic, it's just the truth ๐ค
7. References ๐
the receipts, bestie ๐งพ
7.1. Normative References ๐
[RFC0020] Cerf, V., "ASCII format for network interchange", STD 80,
RFC 20, DOI 10.17487/RFC0020, October 1969,
<https://www.rfc-editor.org/info/rfc20>.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
Requirement Levels", BCP 14, RFC 2119,
DOI 10.17487/RFC2119, March 1997,
<https://www.rfc-editor.org/info/rfc2119>.
[RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data
Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006,
<https://www.rfc-editor.org/info/rfc4648>.
[RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
Specifications: ABNF", STD 68, RFC 5234,
DOI 10.17487/RFC5234, January 2008,
<https://www.rfc-editor.org/info/rfc5234>.
[RFC7230] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Message Syntax and Routing",
RFC 7230, DOI 10.17487/RFC7230, June 2014,
<https://www.rfc-editor.org/info/rfc7230>.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
May 2017, <https://www.rfc-editor.org/info/rfc8174>.
7.2. Informative References ๐ธ
[IEEE754] IEEE, "IEEE Standard for Floating-Point Arithmetic",
DOI 10.1109/IEEESTD.2019.8766229, IEEE 754-2019, July
2019, <https://ieeexplore.ieee.org/document/8766229>.
[RFC7231] Fielding, R., Ed. and J. Reschke, Ed., "Hypertext Transfer
Protocol (HTTP/1.1): Semantics and Content", RFC 7231,
DOI 10.17487/RFC7231, June 2014,
<https://www.rfc-editor.org/info/rfc7231>.
[RFC7493] Bray, T., Ed., "The I-JSON Message Format", RFC 7493,
DOI 10.17487/RFC7493, March 2015,
<https://www.rfc-editor.org/info/rfc7493>.
[RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext
Transfer Protocol Version 2 (HTTP/2)", RFC 7540,
DOI 10.17487/RFC7540, May 2015,
<https://www.rfc-editor.org/info/rfc7540>.
[RFC7541] Peon, R. and H. Ruellan, "HPACK: Header Compression for
HTTP/2", RFC 7541, DOI 10.17487/RFC7541, May 2015,
<https://www.rfc-editor.org/info/rfc7541>.
[RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", STD 90, RFC 8259,
DOI 10.17487/RFC8259, December 2017,
<https://www.rfc-editor.org/info/rfc8259>.
[STD63] Yergeau, F., "UTF-8, a transformation format of ISO
10646", STD 63, RFC 3629, November 2003,
<https://www.rfc-editor.org/info/std63>.
Appendix A. Frequently Asked Questions ๐โโ๏ธ
A.1. Why Not JSON? ๐ค
okay so the earlier versions of Structured Fields were built on JSON [RFC8259] ๐ but here's the tea: making JSON fit inside HTTP header fields meant senders and recipients had to add extra special handling, and that was a whole mess ๐ฉ
JSON has issues with large numbers and with objects that have duplicate members. there's advice for dodging those (e.g., [RFC7493]), but you can't really rely on people following it ๐
JSON strings are Unicode strings by default, which brings a bunch of interoperability headaches (like comparisons getting weird) ๐ implementers can be told to avoid non-ASCII content when it isn't needed, but that's hard to enforce.
then there's JSON nesting to arbitrary depths ๐ that can cause a memory commitment that's not okay for embedded and other limited server deployments, so it needs some kind of limit. the problem is existing JSON implementations don't have any limits, and even if one got specified, some field definition would probably find a reason to break it ๐ญ
because JSON is so widely adopted, it's really hard to put these extra constraints on every implementation, and some deployments would just skip enforcing them, which hurts interoperability. basically, if it looks like JSON, people will be tempted to run a JSON parser or serializer on field values ๐ซ
a big goal for Structured Fields is better interoperability and simpler implementation, so all of this led to a format that needs its own dedicated parser and serializer โจ
and honestly? there were also widely shared feelings that JSON just doesn't "look right" in HTTP fields ๐
Appendix B. Implementation Notes ๐ ๏ธ
a generic implementation of this spec should expose the top-level serialize (Section 4.1) and parse (Section 4.2) functions ๐ they don't have to be literal functions, though. it could be an object with methods for each of the top-level types, and that's totally fine โจ
for interoperability, generic implementations need to be complete and follow the algorithms closely, so see Section 1.1 ๐ง to help with that, the community is maintaining a common test suite at <https://github.com/httpwg/structured-field-tests> ๐งช
heads up, implementers: Dictionaries and Parameters are order-preserving maps ๐บ๏ธ some fields might not give meaning to the ordering of these data types, but the order should still be exposed so applications that need it can use it.
also, it's important to keep Tokens and Strings separate ๐ most programming languages have native types that map to the other types pretty well, so you might need a wrapper "token" object or a parameter on functions to keep these types distinct.
the serialization algorithm isn't strictly limited to the data types in Section 3 in every case ๐ for example, Decimals are designed to take broader input and round it to allowed values.
implementations are allowed to limit the size of different structures, as long as they respect the minimums defined for each type ๐ฆ when a structure goes over an implementation limit, that structure fails parsing or serialization.
Acknowledgements ๐ซถ
many thanks to Matthew Kerwin for his detailed feedback and careful consideration while this spec was being developed ๐
thanks also to Ian Clelland, Roy Fielding, Anne van Kesteren, Kazuho Oku, Evert Pot, Julian Reschke, Martin Thomson, Mike West, and Jeffrey Yasskin for their contributions ๐
Authors' Addresses ๐
Mark Nottingham
Fastly
Prahran VIC
Australia
Email: mnot@mnot.net
URI: https://www.mnot.net/
Poul-Henning Kamp
The Varnish Cache Project
Email: phk@varnish-cache.org
๐ฆ where this page comes from
- ietf: rfc8941 2021-02
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms