Skip to content

Commit cf299e2

Browse files
authored
Merge pull request #2784 from pmeenan/hash
[compression-dictionary] Moved the dictionary hash into the body
2 parents 355d23b + 0e1bfa4 commit cf299e2

1 file changed

Lines changed: 47 additions & 39 deletions

File tree

draft-ietf-httpbis-compression-dictionary.md

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ normative:
4242
HTTP: RFC9110
4343
HTTP-CACHING: RFC9111
4444
RFC5861: # Stale-While-Revalidate
45+
SHA-256: RFC6234
4546
URLPattern:
4647
title: URL Pattern Standard
4748
date: 18 March 2024
@@ -51,8 +52,11 @@ normative:
5152
informative:
5253
Origin: RFC6454
5354
STRUCTURED-FIELDS: RFC8941
54-
SHA-256: RFC6234
5555
RFC7932: # Brotli
56+
SHARED-BROTLI:
57+
title: Shared Brotli Compressed Data Format
58+
date: 28 September 2022
59+
target: https://datatracker.ietf.org/doc/draft-vandevenne-shared-brotli-format/
5660
RFC8878: # Zstandard
5761

5862
--- abstract
@@ -276,26 +280,6 @@ Available-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:
276280
Dictionary-ID: "/v1/main.js 33a64df551425fcc55e4d42a148795d9f25f89d4"
277281
~~~
278282

279-
## Content-Dictionary
280-
281-
When a HTTP server responds with a resource that is encoded with a dictionary
282-
the server MUST send the hash of the dictionary that was used in the
283-
"Content-Dictionary" response header.
284-
285-
The "Content-Dictionary" response header is a Structured Field
286-
{{STRUCTURED-FIELDS}} Byte Sequence containing the {{SHA-256}} hash of the
287-
contents of the dictionary that was used to encode the response.
288-
289-
If the HTTP response contains a "Content-Dictionary" response header with the
290-
hash of a dictionary that the client does not have available then the client
291-
cannot decode or use the HTTP response.
292-
293-
For example:
294-
295-
~~~ http-message
296-
Content-Dictionary: :pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4=:
297-
~~~
298-
299283
# The 'compression-dictionary' Link Relation Type
300284

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

327311
# Dictionary-Compressed Brotli
328312

329-
The "br-d" content encoding identifies a resource that is a
313+
The "dcb" content encoding identifies a resource that is a
330314
"Dictionary-Compressed Brotli" stream.
331315

332-
A "Dictionary-Compressed Brotli" stream is a Brotli {{RFC7932}} stream for a
333-
response that has been compressed with an external dictionary using a
334-
compression window not larger than 16 MB.
316+
A "Dictionary-Compressed Brotli" stream has a fixed header that is followed by
317+
a Shared Brotli {{SHARED-BROTLI}} stream. The header consists of a fixed 4 byte
318+
sequence and a 32 byte hash of the external dictionary that was used. The
319+
Shared Brotli stream is created using the referenced external dictionary and a
320+
compression window that is at most 16 MB in size.
321+
322+
The 36-byte fixed header is as follows:
323+
324+
Magic_Number:
325+
: 4 fixed bytes: 0xff, 0x44, 0x43, 0x42.
326+
327+
SHA_256_Hash:
328+
: 32 Bytes. SHA-256 hash digest of the dictionary {{SHA-256}}.
335329

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

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

343337
# Dictionary-Compressed Zstandard
344338

345-
The "zstd-d" content encoding identifies a resource that is a
339+
The "dcz" content encoding identifies a resource that is a
346340
"Dictionary-Compressed Zstandard" stream.
347341

348-
A "Dictionary-Compressed Zstandard" stream is a Zstandard {{RFC8878}} stream
349-
for a response that has been compressed with an external dictionary.
342+
A "Dictionary-Compressed Zstandard" stream is a binary stream that starts with a
343+
40-byte fixed header and is followed by a Zstandard {{RFC8878}} stream
344+
of the response that has been compressed with an external dictionary.
345+
346+
The 40-byte header consists of a fixed 8-byte sequence followed by the
347+
32-byte SHA-256 hash of the external dictionary that was used to compress the
348+
resource:
349+
350+
Magic_Number:
351+
: 8 fixed bytes: 0x5e, 0x2a, 0x4d, 0x18, 0x20, 0x00, 0x00, 0x00.
352+
353+
SHA_256_Hash:
354+
: 32 Bytes. SHA-256 hash digest of the dictionary {{SHA-256}}.
355+
356+
The 40-byte header is a Zstandard skippable frame (little-endian 0x184D2A5E)
357+
with a 32-byte length (little-endian 0x00000020) that is compatible with existing
358+
Zstandard decoders.
350359

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

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

378387
## Accept-Encoding
379388

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

383392
~~~ http-message
384-
Accept-Encoding: gzip, deflate, br, zstd, br-d, zstd-d
393+
Accept-Encoding: gzip, deflate, br, zstd, dcb, dcz
385394
~~~
386395

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

394403
~~~ http-message
395-
Content-Encoding: br-d
404+
Content-Encoding: dcb
396405
~~~
397406

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

413-
- Name: br-d
422+
- Name: dcb
414423
- Description: "Dictionary-Compressed Brotli" data format.
415424
- Reference: This document
416425
- Notes: {{dictionary-compressed-brotli}}
417426

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

421-
- Name: zstd-d
430+
- Name: dcz
422431
- Description: "Dictionary-Compressed Zstandard" data format.
423432
- Reference: This document
424433
- Notes: {{dictionary-compressed-zstandard}}
@@ -435,7 +444,6 @@ IANA is asked to update the
435444
| Use-As-Dictionary | permanent | {{use-as-dictionary}} of this document |
436445
| Available-Dictionary | permanent | {{available-dictionary}} of this document |
437446
| Dictionary-ID | permanent | {{dictionary-id}} of this document |
438-
| Content-Dictionary | permanent | {{content-dictionary}} of this document |
439447
|----------------------|-----------|-------------------------------------------|
440448

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

456464
# Security Considerations
457465

458-
The security considerations for Brotli {{RFC7932}} and Zstandard
459-
{{RFC8878}} apply to the dictionary-based versions of the respective
460-
algorithms.
466+
The security considerations for Brotli {{RFC7932}}, Shared Brotli
467+
{{SHARED-BROTLI}} and Zstandard {{RFC8878}} apply to the
468+
dictionary-based versions of the respective algorithms.
461469

462470
## Changing content
463471

0 commit comments

Comments
 (0)