Skip to content

Commit

Permalink
Merge pull request #2784 from pmeenan/hash
Browse files Browse the repository at this point in the history
[compression-dictionary] Moved the dictionary hash into the body
  • Loading branch information
pmeenan committed May 20, 2024
2 parents 355d23b + 0e1bfa4 commit cf299e2
Showing 1 changed file with 47 additions and 39 deletions.
86 changes: 47 additions & 39 deletions draft-ietf-httpbis-compression-dictionary.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ normative:
HTTP: RFC9110
HTTP-CACHING: RFC9111
RFC5861: # Stale-While-Revalidate
SHA-256: RFC6234
URLPattern:
title: URL Pattern Standard
date: 18 March 2024
Expand All @@ -51,8 +52,11 @@ normative:
informative:
Origin: RFC6454
STRUCTURED-FIELDS: RFC8941
SHA-256: RFC6234
RFC7932: # Brotli
SHARED-BROTLI:
title: Shared Brotli Compressed Data Format
date: 28 September 2022
target: https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/
RFC8878: # Zstandard

--- abstract
Expand Down Expand Up @@ -276,26 +280,6 @@ Available-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:
Dictionary-ID: "/v1/main.js 33a64df551425fcc55e4d42a148795d9f25f89d4"
~~~

## Content-Dictionary

When a HTTP server responds with a resource that is encoded with a dictionary
the server MUST send the hash of the dictionary that was used in the
"Content-Dictionary" response header.

The "Content-Dictionary" response header is a Structured Field
{{STRUCTURED-FIELDS}} Byte Sequence containing the {{SHA-256}} hash of the
contents of the dictionary that was used to encode the response.

If the HTTP response contains a "Content-Dictionary" response header with the
hash of a dictionary that the client does not have available then the client
cannot decode or use the HTTP response.

For example:

~~~ http-message
Content-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:
~~~

# The 'compression-dictionary' Link Relation Type

This specification defines the 'compression-dictionary' link relation type
Expand Down Expand Up @@ -326,14 +310,24 @@ Link: <https://example.org/dict.dat>; rel="compression-dictionary"

# Dictionary-Compressed Brotli

The "br-d" content encoding identifies a resource that is a
The "dcb" content encoding identifies a resource that is a
"Dictionary-Compressed Brotli" stream.

A "Dictionary-Compressed Brotli" stream is a Brotli {{RFC7932}} stream for a
response that has been compressed with an external dictionary using a
compression window not larger than 16 MB.
A "Dictionary-Compressed Brotli" stream has a fixed header that is followed by
a Shared Brotli {{SHARED-BROTLI}} stream. The header consists of a fixed 4 byte
sequence and a 32 byte hash of the external dictionary that was used. The
Shared Brotli stream is created using the referenced external dictionary and a
compression window that is at most 16 MB in size.

The 36-byte fixed header is as follows:

Magic_Number:
: 4 fixed bytes: 0xff, 0x44, 0x43, 0x42.

SHA_256_Hash:
: 32 Bytes. SHA-256 hash digest of the dictionary {{SHA-256}}.

Clients that announce support for br-d content encoding MUST be able to
Clients that announce support for dcb content encoding MUST be able to
decompress resources that were compressed with a window size of up to 16 MB.

With Brotli compression, the full dictionary is available during compression
Expand All @@ -342,13 +336,28 @@ delta-compression of resources larger than the compression window.

# Dictionary-Compressed Zstandard

The "zstd-d" content encoding identifies a resource that is a
The "dcz" content encoding identifies a resource that is a
"Dictionary-Compressed Zstandard" stream.

A "Dictionary-Compressed Zstandard" stream is a Zstandard {{RFC8878}} stream
for a response that has been compressed with an external dictionary.
A "Dictionary-Compressed Zstandard" stream is a binary stream that starts with a
40-byte fixed header and is followed by a Zstandard {{RFC8878}} stream
of the response that has been compressed with an external dictionary.

The 40-byte header consists of a fixed 8-byte sequence followed by the
32-byte SHA-256 hash of the external dictionary that was used to compress the
resource:

Magic_Number:
: 8 fixed bytes: 0x5e, 0x2a, 0x4d, 0x18, 0x20, 0x00, 0x00, 0x00.

SHA_256_Hash:
: 32 Bytes. SHA-256 hash digest of the dictionary {{SHA-256}}.

The 40-byte header is a Zstandard skippable frame (little-endian 0x184D2A5E)
with a 32-byte length (little-endian 0x00000020) that is compatible with existing
Zstandard decoders.

Clients that announce support for zstd-d content encoding MUST be able to
Clients that announce support for dcz content encoding MUST be able to
decompress resources that were compressed with a window size of at least 8 MB
or 1.25 times the size of the dictionary, which ever is greater, up to a
maximum of 128 MB.
Expand All @@ -373,15 +382,15 @@ negotiating content encoding in HTTP through the "Accept-Encoding" request
header and "Content-Encoding" response header.

The dictionary to use is negotiated separately and advertised in the
"Available-Dictionary" request header and "Content-Dictionary" response header.
"Available-Dictionary" request header.

## Accept-Encoding

The client adds the content encodings that it supports to the "Accept-Encoding"
request header. e.g.:

~~~ http-message
Accept-Encoding: gzip, deflate, br, zstd, br-d, zstd-d
Accept-Encoding: gzip, deflate, br, zstd, dcb, dcz
~~~

## Content-Encoding
Expand All @@ -392,7 +401,7 @@ the client has advertised then it sets the "Content-Encoding" response header
to the appropriate value for the algorithm selected. e.g.:

~~~ http-message
Content-Encoding: br-d
Content-Encoding: dcb
~~~

If the response is cacheable, it MUST include a "Vary" header to prevent caches
Expand All @@ -410,15 +419,15 @@ Vary: accept-encoding, available-dictionary
IANA is asked to enter the following into the "HTTP Content Coding Registry"
registry ({{HTTP}}):

- Name: br-d
- Name: dcb
- Description: "Dictionary-Compressed Brotli" data format.
- Reference: This document
- Notes: {{dictionary-compressed-brotli}}

IANA is asked to enter the following into the "HTTP Content Coding Registry"
registry ({{HTTP}}):

- Name: zstd-d
- Name: dcz
- Description: "Dictionary-Compressed Zstandard" data format.
- Reference: This document
- Notes: {{dictionary-compressed-zstandard}}
Expand All @@ -435,7 +444,6 @@ IANA is asked to update the
| Use-As-Dictionary | permanent | {{use-as-dictionary}} of this document |
| Available-Dictionary | permanent | {{available-dictionary}} of this document |
| Dictionary-ID | permanent | {{dictionary-id}} of this document |
| Content-Dictionary | permanent | {{content-dictionary}} of this document |
|----------------------|-----------|-------------------------------------------|

## Link Relation Registration
Expand All @@ -455,9 +463,9 @@ be used in secure contexts (HTTPS).

# Security Considerations

The security considerations for Brotli {{RFC7932}} and Zstandard
{{RFC8878}} apply to the dictionary-based versions of the respective
algorithms.
The security considerations for Brotli {{RFC7932}}, Shared Brotli
{{SHARED-BROTLI}} and Zstandard {{RFC8878}} apply to the
dictionary-based versions of the respective algorithms.

## Changing content

Expand Down

0 comments on commit cf299e2

Please sign in to comment.