Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compression-dictionary] Moved the dictionary hash into the body #2784

Merged
merged 4 commits into from
May 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 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,7 +52,6 @@ normative:
informative:
Origin: RFC6454
STRUCTURED-FIELDS: RFC8941
SHA-256: RFC6234
RFC7932: # Brotli
RFC8878: # Zstandard

Expand Down Expand Up @@ -276,26 +276,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 +306,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 Brotli {{RFC7932}} stream. The header consists of a fixed 4 byte sequence
and a 32 byte hash of the external dictionary that was used. The 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.

Clients that announce support for br-d content encoding MUST be able to
SHA_256_Hash:
: 32 Bytes. SHA-256 hash digest of the dictionary {{SHA-256}}.

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 +332,24 @@ 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
36-byte fixed header and is followed by a Zstandard {{RFC8878}} stream
of the response that has been compressed with an external dictionary.

The 36-byte stream header consists of a 4-byte signature followed by the
32-byte SHA-256 hash of the external dictionary that was used to compress the
resource:

Magic_Number:
: 4 fixed bytes: 0xff, 0x44, 0x45, 0x5a.

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

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 +374,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 +393,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 +411,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 +436,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 Down
Loading