<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='lib/rfc2629.xslt' ?>

<!--<?rfc header="Documentation"?>-->
<!--?rfc private="RFC2629 through XSLT"?-->
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc linkmailto="no"?>
<?rfc editing="no"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?ref rfcedstyle="yes"?>
<?rfc-ext allow-markup-in-artwork="yes" ?>
<?rfc-ext include-index="no" ?>
<!-- <?rfc topblock="no"?> -->
<!--<?rfc strict="no"?>-->

<rfc category="info"
    ipr="trust200902"
    docName="draft-ruellan-reference-set-definition-00"
    >
    <front>
        <title abbrev="Reference Set Definition">HTTP/2.0: Header Reference Set Definition</title>

        <author initials="H." surname="Ruellan" fullname="Herve Ruellan">
            <organization>Canon CRF</organization>
            <address>
                <email>herve.ruellan@crf.canon.fr</email>
            </address>
        </author>
        <author initials="J" surname="Fujisawa" fullname="Jun Fujisawa">
            <organization>Canon, Inc.</organization>
            <address>
                <postal>
                    <street>3-30-2 Shimomaruko</street>
                    <city>Ohta-ku, Tokyo </city>
                    <region></region>
                    <code>146-8501</code>
                    <country>Japan</country>
                </postal>
                <email>fujisawa.jun@canon.co.jp</email>
            </address>
        </author>
        <author initials="R" surname="Bellessort" fullname="Romain Bellessort">
            <organization>Canon CRF</organization>
            <address>
                <email>romain.bellessort@crf.canon.fr</email>
            </address>
        </author>
        <author initials="Y" surname="Fablet" fullname="Youenn Fablet">
            <organization>Canon CRF</organization>
            <address>
                <email>youenn.fablet@crf.canon.fr</email>
            </address>
        </author>


        <date month="July" year="2013"/>
        <area>Applications</area>
        <workgroup>HTTPbis Working Group</workgroup>
        <keyword>HTTP</keyword>
        <keyword>Header</keyword>
        <abstract>
            <t>
                This document describes modifications of the proposed HTTP/2.0
                header compression mechanism for the definition of the
                reference set used to encode a set of headers.
            </t>
        </abstract>
    </front>

    <middle>
        <section title="Introduction">
            <t>
                In <xref target="http2.0">HTTP/2.0</xref>, HTTP headers are
                compressed according to the <xref
                    target="header-compression">HTTP/2.0 Headers
                    Compression</xref> draft. This compression format relies
                on the previous set of headers to improve compression. Two
                consecutive sets of headers often comprise a significant
                number of headers in common. Encoding the differences between
                those two sets is generally more efficient than encoding the
                set of headers itself.
            </t>

            <t>
                The messages exchanged between a client and a server (or
                between a server and a client) may however comprise different
                types of header sets: GET requests and POST requests may have
                more differences than similarities; "200 OK" responses and "304
                Not Modified" responses may be very different. In those cases,
                allowing the encoder to select a specific reference set of
                headers allows reducing the size of encoded headers.
            </t>

            <t>
                A new mechanism is proposed in this draft to allow the encoder
                defining a reference set of headers directly from the header
                indexing table.
            </t>
        </section>
        <section title="Overview">
            <section title="Design Principles">
                <t>
                    This proposal builds on <xref
                        target="header-compression">HTTP/2.0 Header
                        Compression</xref> to further improve the compactness
                    of HTTP headers representation. It reuses the notion of
                    header group as defined in <xref target="delta2">Header
                        Delta-Compression for HTTP/2.0</xref> in a more limited
                    way. First, NO additional indexing structure or storage
                    requirement is added to the existing mechanisms defined in
                    <xref target="header-compression">HTTP/2.0 Header
                        Compression</xref>. Second, the impact on
                    implementations, particularly on decoder side, should be
                    as limited as possible. This proposal may also bring
                    processing improvements.
                    qdfsq

                </t>
            </section>
            <section title="Outline">
                <t>
                    Using this proposal, when encoding a new set of headers,
                    the encoder indicates whether it relies on the default
                    reference set (i.e. the previous set of headers) or
                    whether it defines a specific reference set. 
                </t>

                <t>
                    A specific reference set is represented as a start index
                    SI and a length L; the reference set is defined as the L
                    headers occurring from index SI in the header indexing
                    table. 
                </t>

                <t>
                    Once this specific reference set is defined, it is used in
                    place of the default reference set to encode the new set
                    of headers: only the differences between this specific
                    reference set and the new set of headers are represented.
                </t>
            </section>
        </section>
        <section title="Integration Within Current Draft">
            <t>
                A new flag, REFERENCE_SET, is defined for the HEADERS frame.
                This flag uses bit 5 (0x10) and determines whether the default
                reference set or another one is used for the given Header
                Block.
            </t>

            <t>
                The value of 0 indicates that the default reference set (i.e.
                the previous set of headers) is used and the header block
                contains the differences between the reference set and the set
                of headers represented.
            </t>

            <t>
                The value of 1 indicates that the header block starts by the
                definition of a specific reference set, which is then followed
                by the differences between this specitic reference set and the
                set of headers represented.
            </t>
        </section>
        <section title="Detailed Format">
            <section title="Header Block Organization">
                <t>
                    A header block is organized in two parts:
                    <list style="symbols">
                        <t>
                            An optional reference set definition. This
                            definition is present only if the REFERENCE_SET
                            flag is set.
                        </t>
                        <t>
                            A list of difference between the reference set and
                            the encoded set of headers. The difference is
                            represented as defined in <xref
                                target="header-compression">HTTP/2.0 Header
                                Compression</xref>.
                        </t>
                    </list>
                </t>
            </section>
            <section title="Reference Set Definition">
                <t>
                    A reference set is described on 2 bytes.
                </t>
                <t>
                    <figure title="Reference Set Definition">
                        <artwork type="inline">
  0                                       1
  0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
+-------------------+-------------------------------------------+
|    Length (5)     |             Start Index (11)              |
+-------------------+-------------------------------------------+
</artwork>
                    </figure>
                </t>
                <t>
                    The fields defining a reference set are:
                    <list style="hanging">
                        <t hangText="Length:">
                            The length of the reference set, encoded on 5
                            bits. This length is comprised between 0 and 31.
                        </t>
                        <t hangText="Start Index:">
                            The index of the first entry of the reference set
                            in the header table.  If the reference set length
                            is strictly greater than zero, the start index is
                            encoded on 11 bits. If the length is equal to
                            zero, the start index value is zero and is encoded
                            on 3 bits.
                        </t>
                    </list>
                </t>
            </section>
        </section>
        <section title="Empty Reference Set">
            <t>
                If the reference set length is equal to zero, the reference
                set is empty and the reference set definition is optimized to
                use only one byte.
            </t>
                <t>
                    <figure title="Empty Reference Set Definition">
                        <artwork type="inline">
  0   1   2   3   4   5   6   7
+-------------------+-----------+
|         0         |     0     |
+-------------------+-----------+
</artwork>
                    </figure>
                </t>
            <t>
                This special case may be useful in a number of applications.
                First, it can allow a more compact encoding of a header set.
                For instance, measurements have shown that using the empty as
                the reference set is, for a fair number of test samples, more
                efficient than using the default reference set for HTTP
                responses.
            </t>
            <t>
                Second, using the empty set allows reducing the coding
                complexity for the encoder. This can be useful for server or
                intermediaries under a heavy load. It could also be used by
                lightweight devices that prefer using static encoding
                strategies.
            </t>
        </section>
        <section title="Open Questions">
            <section title="Reference Set Removals">
                <t>
                    The definition of a specific reference set is based on a
                    contiguous set of header entries in the header indexing
                    table. Removing a header from the set is typically encoded
                    using one or two bytes.  It may be beneficial to optimize
                    the removal of a header in the case of a specific
                    reference set which would be constituted of several
                    contiguous sets of headers separated by a few other
                    headers not belonging to the set of headers to encode.
                </t>

                <t>
                    For instance, for a sixteen headers reference set, two
                    bytes are needed to define all the removals as an array of
                    booleans.
                    Two bytes is also the cost for encoding one or two
                    removals using
                    <xref target="header-compression">HTTP/2.0 Header
                        Compression</xref>. Once a reference set of sixteen
                    headers contains more than two headers that should be
                    removed, using an array of booleans is more efficient.
                </t>

                <t>
                    Early experiments show that this approach allows selecting
                    larger reference sets and brings noticeable compaction
                    benefits. Additional investigation should be done to
                    understand how optimized indexing table building would
                    decrease the benefits.
                </t>

                <t>
                    Encoding the removals as an array of booleans has also the
                    advantage of making decoder implementations simpler. As
                    removals are not encoded in the same way as indexed
                    values, there is no problem of handling possible
                    discrepancies between the index values in the reference
                    set and the index values in the header table.
                </t>

                <t>
                    Optimized encoding of the header removal could also be
                    envisioned for the default reference set. In such a case,
                    an ordering of the default reference set headers should be
                    defined. Such an ordering could be based on the indexes of
                    the headers.
                </t>

                <t>
                    Additional study should be conducted to evaluate whether
                    this feature should be a mandatory part of the specific
                    reference set definition or an option. Several ways to
                    switch on/off this feature may be envisioned: using a
                    specific HEADERS frame flag; using a specific bit within
                    the reference set definition. Using a specific HEADERS
                    frame flag would be appropriate if using deletions for the
                    default reference set is envisioned.
                </t>
            </section>
            <section title="Adapted Entries Insertion/Removal">
                <t>
                    Rules to handle incremental indexing and batch entry
                    removal in case of buffer overflow are defined in <xref
                        target="header-compression">HTTP/2.0 Header
                        Compression</xref>. New rules may be defined when
                    specific reference sets are used.
                </t>

                <t>
                    Incrementally indexed entries could be inserted just after
                    the last entry in the header indexing table that is part
                    of the specific reference set. If entry removal is needed,
                    removal could start with the first entry after the last
                    incrementally indexed header or just after the last entry
                    that is part of the specific reference set. 
                </t>

                <t>
                    Additional study of the processing cost of these rules
                    should be envisioned.
                </t>
            </section>
            <section title="Optimized Reference Set Definition">
                <t>
                    A single representation of the reference header set is
                    currently specified. This representation generally
                    requires 2 bytes to be encoded. Tests involving a single
                    byte representation have been made and have shown a small
                    benefit. Based on additional tests, a more optimized
                    representation could be defined.
                </t>
            </section>
            <section title="Re-indexing of Already Indexed Headers">
                <t>
                    If the same header happens in several reference sets, it
                    may be beneficial to insert such header at several places
                    in the header indexing table. While it makes the header
                    indexing table size bigger, it may further improve future
                    reference set definitions. 
                </t>

                <t>
                    This approach is already feasible by encoding a header
                    literally several times. It may be optimized by enabling
                    to insert at a new place a header that is already
                    represented as an indexed header.
                </t>
            </section>
        </section>

        <section title="Security Considerations">
            <t>
                TBD.
            </t>
        </section>

        <section title="IANA Considerations">
            <t>
                This memo includes no request to IANA.
            </t>
        </section>
    </middle>

    <back>
        <references title="Normative References">
            <reference anchor="http2.0">
                <front>
                    <title abbrev="HTTP/2.0">Hypertext Transfer Protocol version 2.0</title>

                    <author initials="M." surname="Belshe" fullname="Mike Belshe"/>
                    <author initials="R." surname="Peon" fullname="Roberto Peon"/>
                    <author initials="M." surname="Thomson" fullname="Martin Thomson" role="editor"/>
                    <author initials="A." surname="Melnikov" fullname="Alexey Melnikov" role="editor"/>
                    <date month="July" year="2013"/>
                </front>
                <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-http2-04" />
            </reference>

            <reference anchor="header-compression">
                <front>
                    <title>HTTP/2.0 Header Compression</title>
                    <author initials="H." surname="Ruellan" fullname="Herve Ruellan"/>
                    <author initials="R." surname="Peon" fullname="Roberto Peon"/>
                    <date month="July" year="2013" />
                </front>
                <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-header-compression-01" />
            </reference>
        </references>

        <references title="Informative References">
            <reference anchor="delta2">
                <front>
                    <title>Header Delta-Compression for HTTP/2.0</title>
                    <author initials="R." surname="Peon" fullname="Roberto Peon"/>
                    <date month="March" year="2013" />
                </front>
                <seriesInfo name="Internet-Draft" value="draft-rpeon-httpbis-header-compression-03" />
            </reference>

            <reference anchor="bohe">
                <front>
                    <title>HTTP/2.0 Discussion: Stored Header Encoding</title>
                    <author initials="J." surname="Snell" fullname="James Snell"/>
                    <date month="July" year="2013" />
                </front>
                <seriesInfo name="Internet-Draft" value="draft-snell-httpbis-bohe-11" />
            </reference>
        </references>

        <section title="Example">
            <t>
                After the transmission of a "200 OK" and "304 Not Modified"
                responses, the header indexing table is as follows:
            </t>
            <t>
                <figure title="Initial Header Table">
                    <artwork>
+---------+----------------+---------------------------+
|  Index  | Header Name    | Header Value              |
+---------+----------------+---------------------------+
|    0    | :status        | 200                       |
+---------+----------------+---------------------------+
|    1    | cache-control  | public                    |
+---------+----------------+---------------------------+
|    2    | content-type   | text/html                 |
+---------+----------------+---------------------------+
|    3    | content-length | 32                        |
+---------+----------------+---------------------------+
|    4    | expires        | 01 Apr 2014 00:00:00 GMT  |
+---------+----------------+---------------------------+
|    5    | :status        | 304                       |
+---------+----------------+---------------------------+
|    6    | expires        | 01 Apr 2015 00:00:00 GMT  |
+---------+----------------+---------------------------+
</artwork>
                </figure>
            </t>
            <t>
                The current reference set is:
            </t>
            <t>
                <figure title="Initial Header Table">
                    <artwork>
5    :status: 304
6    expires: 01 Apr 2015 00:00:00 GMT
</artwork>
                </figure>
            </t>
            <t>
                The next response is a "200 OK" response. The following
                headers have to be encoded:
            </t>
            <t>
                <figure title="Initial Header Table">
                    <artwork>
:status: 200
cache-control: public
content-type: text/html
content-length: 1034
expires: 01 Apr 2016 00:00:00 GMT
</artwork>
                </figure>
            </t>
            <section title="Default Reference Set Example">
                <t>
                    The following stream illustrates the "200 OK" response
                    header set encoded as reference to the previous message:
            </t>
            <t>
                <figure title="Initial Header Table">
                    <artwork>
0x85    (Indexed header, index = 5, removal)
0x86    (Indexed header, index = 6, removal)
0x80    (Indexed header, index = 0)
0x81    (Indexed header, index = 1)
0x82    (Indexed header, index = 2)
0x44    (Literal header with incremental indexing, name index = 3)
0x04    (Header value string length = 4)
1034
0x45    (Literal header with incremental indexing, name index = 4)
0x18    (Header value string length = 24)
01 Apr 2016 00:00:00 GMT
</artwork>
                    </figure>
                </t>
                <t>
                    The size of the encoded header set is 37 bytes.
                </t>
            </section>
            <section title="Empty Reference Set Example">
                <t>
                    The following stream illustrates the "200 OK" response
                    header set encoded as reference to an empty reference set:
            </t>
            <t>
                <figure title="Initial Header Table">
                    <artwork>
0x00    (Empty reference set)
0x80    (Indexed header, index = 0)
0x81    (indexed header, index = 1)
0x82    (indexed header, index = 2)
0x44    (Literal header with incremental indexing, name index = 3)
0x04    (Header value string length = 4)
1034
0x45    (Literal header with incremental indexing, name index = 4)
0x18    (Header value string length = 24)
01 Apr 2016 00:00:00 GMT
</artwork>
                    </figure>
                </t>
                <t>
                    The size of the encoded header set is 36 bytes.
                </t>
            </section>
            <section title="Specific Reference Set Example">
                <t>
                    The following stream illustrates the "200 OK" response
                    header set encoded as reference to a specific reference
                    set (Length = 3, Start Index = 0):
            </t>
            <t>
                <figure title="Initial Header Table">
                    <artwork>
0x18 0x00 (specific reference set, length = 3, start index = 0)
0x44    (Literal header with incremental indexing, name index = 3)
0x04    (Header value string length = 4)
1034
0x45    (Literal header with incremental indexing, name index = 4)
0x18    (Header value string length = 24)
01 Apr 2016 00:00:00 GMT
</artwork>
                    </figure>
                </t>
                <t>
                    The size of the encoded header set is 34 bytes.
                </t>
            </section>
        </section>
    </back>
</rfc>
<!--
  vim:et:tw=78:sw=4:
 -->
