<?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
  ]>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>

<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
     docName="draft-lindqvist-zstdict-01"
     category="info"
     ipr="trust200902"
     submissionType="IETF">

  <front>
    <title abbrev="zstdict">Zstandard Dictionary Content-Encoding</title>
    <seriesInfo name="Internet-Draft" value="draft-lindqvist-zstdict-01"/>
    <author fullname="Peter Lindqvist">
      <organization>Independent</organization>
      <address>
        <postal>
          <city>Stockholm</city>
          <country>Sweden</country>
        </postal>
        <email>bruhbruhbruh893@gmail.com</email>
      </address>
    </author>
    <date year="2026" month="October" day="20"/>
    <area>Applications</area>
    <workgroup>HTTP</workgroup>
    <abstract>
      <t>This document defines a new HTTP content coding, "zstdict", which
      enables Zstandard compression with a pre-shared dictionary. The
      dictionary is identified by a SHA-256 hash and negotiated via the
      Content-Dict response header.</t>
    </abstract>
  </front>

  <middle>
    <section anchor="introduction" numbered="true" toc="default">
      <name>Introduction</name>
      <t>Zstandard <xref target="RFC8878"/> is a compression algorithm that supports
      dictionaries for improved compression of small payloads. This
      document defines a new HTTP content coding, "zstdict", to signal
      Zstandard compression with a pre-shared dictionary.</t>
      <t>The dictionary is identified by its SHA-256 hash. Clients MUST
      verify the hash before decoding.</t>
    </section>

    <section anchor="content-coding" numbered="true" toc="default">
      <name>The "zstdict" Content Coding</name>
      <t>The "zstdict" content coding is identical to "zstd" <xref target="RFC8878"/>,
      except that a dictionary is used for both compression and
      decompression.</t>
      <t>A response using "zstdict" MUST include a Content-Dict header
      containing the SHA-256 hash of the dictionary, in lowercase hex.</t>
      <t>Example:</t>
      <artwork><![CDATA[
  Content-Encoding: zstdict
  Content-Dict: sha256-89ff6702e9d396f01bdf8865451521d2ba23efce9c5968c784b85744d6e55faf
      ]]></artwork>
    </section>

    <section anchor="content-dict" numbered="true" toc="default">
      <name>The Content-Dict Header</name>
      <t>The Content-Dict header identifies the dictionary used for
      compression. Its value is a hash algorithm identifier followed by
      the hex-encoded hash.</t>
      <artwork><![CDATA[
  Content-Dict = "sha256-" 64HEXDIG
      ]]></artwork>
    </section>

    <section anchor="distribution" numbered="true" toc="default">
      <name>Dictionary Distribution</name>
      <t>The dictionary MUST be available to the client before decoding.
      Three distribution mechanisms are defined:</t>
      
      <section anchor="well-known" numbered="true" toc="default">
        <name>Well-Known URI</name>
        <t>Servers MAY publish dictionaries at:</t>
        <artwork><![CDATA[
  /.well-known/zstdict/<hash>
        ]]></artwork>
        <t>where &lt;hash&gt; is the SHA-256 hash from Content-Dict. Clients MAY
        fetch this URI on first encounter and cache it.</t>
      </section>

      <section anchor="app-bundled" numbered="true" toc="default">
        <name>Application-Bundled</name>
        <t>Clients MAY ship dictionaries with the application. In this case,
        the Content-Dict header is informational and the client uses the
        bundled dictionary matching the hash.</t>
      </section>

      <section anchor="link-header" numbered="true" toc="default">
        <name>Reference Implementation</name>
        <t>A reference dictionary and C library implementation for this specification are available at:</t>
        <artwork><![CDATA[
  https://github.com/pngz-dev/zstdict.git
        ]]></artwork>
      </section>
    </section>

    <section anchor="security" numbered="true" toc="default">
      <name>Security Considerations</name>
      <t>Dictionary deserialization is a known attack vector. Clients
      MUST validate the dictionary hash before use. Malicious
      dictionaries can cause denial of service. Implementations MUST
      limit the maximum size of accepted dictionaries.</t>
    </section>

    <section anchor="iana" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>This document registers "zstdict" in the HTTP Content Coding
      Registry.</t>
      <dl>
        <dt>Name:</dt><dd>zstdict</dd>
        <dt>Description:</dt><dd>Zstandard compression with pre-shared dictionary</dd>
        <dt>Reference:</dt><dd>this document</dd>
      </dl>
    </section>
  </middle>

  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="RFC8878">
        <front>
          <title>Zstandard Compression and the 'application/zstd' Media Type</title>
          <author initials="Y." surname="Collet"><organization/></author>
          <author initials="M." surname="Kucherawy"><organization/></author>
          <date month="February" year="2021"/>
        </front>
        <seriesInfo name="RFC" value="8878"/>
      </reference>
    </references>
  </back>
</rfc>
