Internet-Draft | Retrofit Structured Fields | June 2022 |
Nottingham | Expires 10 December 2022 | [Page] |
This specification nominates a selection of existing HTTP fields as having syntax that is compatible with Structured Fields, so that they can be handled as such (subject to certain caveats).¶
To accommodate some additional fields whose syntax is not compatible, it also defines mappings of their semantics into new Structured Fields. It does not specify how to negotiate their use.¶
This note is to be removed before publishing as an RFC.¶
Status information for this document may be found at https://datatracker.ietf.org/doc/draft-ietf-httpbis-retrofit/.¶
Discussion of this document takes place on the HTTP Working Group mailing list (mailto:ietf-http-wg@w3.org), which is archived at https://lists.w3.org/Archives/Public/ietf-http-wg/. Working Group information can be found at https://httpwg.org/.¶
Source for this draft and an issue tracker can be found at https://github.com/httpwg/http-extensions/labels/retrofit.¶
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.¶
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.¶
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."¶
This Internet-Draft will expire on 10 December 2022.¶
Copyright (c) 2022 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) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License.¶
Structured Field Values for HTTP [STRUCTURED-FIELDS] introduced a data model with associated parsing and serialization algorithms for use by new HTTP field values. Fields that are defined as Structured Fields can realise a number of benefits, including:¶
However, a field needs to be defined as a Structured Field for these benefits to be realised. Many existing fields are not, making up the bulk of header and trailer fields seen in HTTP traffic on the internet.¶
This specification defines how a selection of existing HTTP fields can be handled as Structured Fields, so that these benefits can be realised -- thereby making them Retrofit Structured Fields.¶
It does so using two techniques. Section 2 lists compatible fields -- those that can be handled as if they were Structured Fields due to the similarity of their defined syntax to that in Structured Fields. Section 3 lists mapped fields -- those whose syntax needs to be transformed into an underlying data model which is then mapped into that defined by Structured Fields.¶
Note that while implementations can parse and serialise compatible fields as Structured Fields subject to the caveats in Section 2, a sender cannot generate mapped fields from Section 3 and expect them to be understood and acted upon by the recipient without prior negotiation. This specification does not define such a mechanism.¶
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.¶
The HTTP fields listed in Table 1 can usually have their values handled as Structured Fields according to the listed parsing and serialisation algorithms in [STRUCTURED-FIELDS], subject to the listed caveats.¶
The listed types are chosen for compatibility with the defined syntax of the field as well as with actual internet traffic. However, not all instances of these fields will successfully parse. This might be because the field value is clearly invalid, or it might be because it is valid but not parseable as a Structured Field.¶
An application using this specification will need to consider how to handle such field values. Depending on its requirements, it might be advisable to reject such values, treat them as opaque strings, or attempt to recover a structured value from them in an ad hoc fashion.¶
Field Name | Structured Type |
---|---|
Accept | List |
Accept-Encoding | List |
Accept-Language | List |
Accept-Patch | List |
Accept-Post | List |
Accept-Ranges | List |
Access-Control-Allow-Credentials | Item |
Access-Control-Allow-Headers | List |
Access-Control-Allow-Methods | List |
Access-Control-Allow-Origin | Item |
Access-Control-Expose-Headers | List |
Access-Control-Max-Age | Item |
Access-Control-Request-Headers | List |
Access-Control-Request-Method | Item |
Age | Item |
Allow | List |
ALPN | List |
Alt-Svc | Dictionary |
Alt-Used | Item |
Cache-Control | Dictionary |
CDN-Loop | List |
Clear-Site-Data | List |
Connection | List |
Content-Encoding | List |
Content-Language | List |
Content-Length | List |
Content-Type | Item |
Cross-Origin-Resource-Policy | Item |
Expect | Dictionary |
Expect-CT | Dictionary |
Forwarded | Dictionary |
Host | Item |
Keep-Alive | Dictionary |
Max-Forwards | Item |
Origin | Item |
Pragma | Dictionary |
Prefer | Dictionary |
Preference-Applied | Dictionary |
Retry-After | Item |
Sec-WebSocket-Extensions | List |
Sec-WebSocket-Protocol | List |
Sec-WebSocket-Version | Item |
Server-Timing | List |
Surrogate-Control | Dictionary |
TE | List |
Timing-Allow-Origin | List |
Trailer | List |
Transfer-Encoding | List |
Vary | List |
X-Content-Type-Options | Item |
X-Frame-Options | Item |
X-XSS-Protection | List |
Note the following caveats regarding compatibility:¶
HTTP parameter names are case-insensitive (per Section 5.6.6 of [HTTP]), but Structured Fields require them to be all-lowercase. Although the vast majority of parameters seen in typical traffic are all-lowercase, compatibility can be improved by force-lowercasing parameters when parsing. Likewise, many Dictionary-based fields (e.g., Cache-Control, Expect-CT, Pragma, Prefer, Preference-Applied, Surrogate-Control) have case-insensitive keys, and compatibility can be improved by force-lowercasing them when parsing.¶
The parameters rule in HTTP (see Section 5.6.6 of [HTTP]) allows whitespace before the ";" delimiter, but Structured Fields does not. Compatibility can be improved by allowing such whitespace when parsing.¶
Section 5.6.4 of [HTTP] allows backslash-escaping most characters in quoted strings, whereas Structured Field Strings only escape "\" and DQUOTE. Compatibility can be improved by unescaping other characters before parsing.¶
In Structured Fields, tokens are required to begin with an alphabetic character or "*", whereas HTTP tokens allow a wider range of characters. This prevents use of mapped values that begin with one of these characters. For example, media types, field names, methods, range-units, character and transfer codings that begin with a number or special character other than "*" might be valid HTTP protocol elements, but will not be able to be parsed as Structured Field Tokens.¶
Structured Fields Integers can have at most 15 digits; larger values will not be able to be represented in them.¶
Fields whose values contain IPv6 literal addresses (such as CDN-Loop, Host, and Origin) are not able to be represented as Structured Fields Tokens, because the brackets used to delimit them are not allowed in Tokens.¶
Empty and whitespace-only field values are considered errors in Structured Fields. For compatible fields, an empty field indicates that the field should be silently ignored.¶
Some ALPN tokens (e.g., h3-Q43
) do not conform to key's syntax, and therefore cannot be represented as a Token. Since the final version of HTTP/3 uses the h3
token, this shouldn't be a long-term issue, although future tokens may again violate this assumption.¶
Note that Content-Length is defined as a List because it is not uncommon for implementations to mistakenly send multiple values. See Section 8.6 of [HTTP] for handling requirements.¶
Only the delta-seconds form of Retry-After can be represented; a Retry-After value containing a http-date will need to be converted into delta-seconds to be conveyed as a Structured Field Value.¶
Some HTTP field values have syntax that cannot be successfully parsed as Structured Fields. Instead, it is necessary to map them into a separate Structured Field with an alternative name.¶
For example, the Date HTTP header field carries a date:¶
Its value is more efficiently represented as an Integer number of delta seconds from the Unix epoch (00:00:00 UTC on 1 January 1970, minus leap seconds). Thus, the example above would be mapped to:¶
As in Section 2, these fields are unable to carry values that are not valid Structured Fields, and so an application using this specification will need to how to support such values. Typically, handling them using the original field name is sufficient.¶
Each field name listed below indicates a replacement field name and a means of mapping its original value into a Structured Field.¶
The field names in Table 2 (paired with their mapped field names) have values that can be mapped into Structured Fields by treating the original field's value as a String.¶
Field Name | Mapped Field Name |
---|---|
Content-Location | SF-Content-Location |
Location | SF-Location |
Referer | SF-Referer |
For example, a Location field could be mapped as:¶
The field names in Table 3 (paired with their mapped field names) have values that can be mapped into Structured Fields by parsing their payload according to Section 5.6.7 of [HTTP] and representing the result as an Integer number of seconds delta from the Unix Epoch (00:00:00 UTC on 1 January 1970, excluding leap seconds).¶
Field Name | Mapped Field Name |
---|---|
Date | SF-Date |
Expires | SF-Expires |
If-Modified-Since | SF-IMS |
If-Unmodified-Since | SF-IUS |
Last-Modified | SF-LM |
For example, an Expires field could be mapped as:¶
Please add the following note to the "Hypertext Transfer Protocol (HTTP) Field Name Registry":¶
The "Structured Type" column indicates the type of the field (per RFC8941), if any, and may be "Dictionary", "List" or "Item". A prefix of "*" indicates that it is a retrofit type (i.e., not natively Structured); see [this specification].¶
Note that field names beginning with characters other than ALPHA or "*" will not be able to be represented as a Structured Fields Token, and therefore may be incompatible with being mapped into fields that refer to it; see [this specification].¶
Then, add a new column, "Structured Type", with the values from Section 2 assigned to the nominated registrations, prefixing each with "*" to indicate that it is a retrofit type.¶
Then, add the field names in Table 5, with the corresponding Structured Type as indicated, a status of "permanent" and referring to this document.¶
Field Name | Structured Type |
---|---|
SF-Content-Location | String |
SF-Cookie | List |
SF-Date | Item |
SF-ETag | Item |
SF-Expires | Item |
SF-IMS | Item |
SF-INM | List |
SF-IUS | Item |
SF-Link | List |
SF-LM | Item |
SF-Location | String |
SF-Referer | String |
SF-Set-Cookie | Dictionary |
Finally, add the indicated Structured Type for each existing registry entry listed in Table 6.¶
Field Name | Structured Type |
---|---|
Accept-CH | List |
Cache-Status | List |
CDN-Cache-Control | Dictionary |
Cross-Origin-Embedder-Policy | Item |
Cross-Origin-Embedder-Policy-Report-Only | Item |
Cross-Origin-Opener-Policy | Item |
Cross-Origin-Opener-Policy-Report-Only | Item |
Origin-Agent-Cluster | Item |
Priority | Dictionary |
Proxy-Status | List |
Section 2 identifies existing HTTP fields that can be parsed and serialised with the algorithms defined in [STRUCTURED-FIELDS]. Variances from existing parser behavior might be exploitable, particularly if they allow an attacker to target one implementation in a chain (e.g., an intermediary). However, given the considerable variance in parsers already deployed, convergence towards a single parsing algorithm is likely to have a net security benefit in the longer term.¶
Section 3 defines alternative representations of existing fields. Because downstream consumers might interpret the message differently based upon whether they recognise the alternative representation, implementations are prohibited from generating such fields unless they have negotiated support for them with their peer. This specification does not define such a mechanism, but any such definition needs to consider the implications of doing so carefully.¶