QUIC                                                           C. Krasic
Internet-Draft                                               Google, Inc                                                   Netflix
Intended status: Standards Track                               M. Bishop
Expires: November 24, December 30, 2018                           Akamai Technologies
                                                        A. Frindell, Ed.
                                                                Facebook
                                                            May 23,
                                                           June 28, 2018

              QPACK: Header Compression for HTTP over QUIC
                        draft-ietf-quic-qpack-00
                        draft-ietf-quic-qpack-01

Abstract

   This specification defines QPACK, a compression format for
   efficiently representing HTTP header fields, to be used in HTTP over
   QUIC.  This is a variation of HPACK header compression that seeks to
   reduce head-of-line blocking.

Note to Readers

   Discussion of this draft takes place on the QUIC working group
   mailing list (quic@ietf.org), which is archived at
   https://mailarchive.ietf.org/arch/search/?email_list=quic [1].

   Working Group information can be found at https://github.com/quicwg
   [2]; source code and issues list for this draft can be found at
   https://github.com/quicwg/base-drafts/labels/-qpack [3].

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at https://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on November 24, December 30, 2018.

Copyright Notice

   Copyright (c) 2018 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (https://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Simplified BSD License text as described in Section 4.e of
   the Trust Legal Provisions and are provided without warranty as
   described in the Simplified BSD License.

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   3
     1.1.  Head-of-Line Blocking in HPACK
   2.  Header Tables . . . . . . . . . . . . .   3
     1.2.  Avoiding Head-of-Line Blocking in HTTP/QUIC . . . . . . .   4
   2.  Conventions and Definitions . . . .   3
     2.1.  Static Table  . . . . . . . . . . . . .   5
     2.1.  Notational Conventions . . . . . . . . .   4
     2.2.  Dynamic Table . . . . . . . .   5
   3.  Wire Format . . . . . . . . . . . . . .   4
       2.2.1.  Absolute and Relative Indexing  . . . . . . . . . . .   5
     3.1.  Primitives
       2.2.2.  Post-Base Indexing  . . . . . . . . . . . . . . . . .   6
     2.3.  Avoiding Head-of-Line Blocking in HTTP/QUIC . . . . . . .   7
       2.3.1.  State Synchronization .   6
     3.2.  Indexing . . . . . . . . . . . . . . .   8
   3.  Conventions and Definitions . . . . . . . . .   6
     3.3.  QPACK Encoder Stream . . . . . . . .   8
     3.1.  Notational Conventions  . . . . . . . . . .   8
       3.3.1.  Insert With Name Reference . . . . . . .   9
   4.  Configuration . . . . . .   8
       3.3.2.  Insert Without Name Reference . . . . . . . . . . . .   9
       3.3.3.  Duplicate . . . . . .   9
   5.  Wire Format . . . . . . . . . . . . . . . .   9
       3.3.4.  Dynamic Table Size Update . . . . . . . . .   9
     5.1.  Primitives  . . . . .  10
     3.4.  QPACK Decoder Stream . . . . . . . . . . . . . . . . . .  10
       3.4.1.  Table State Synchronize
       5.1.1.  Prefixed Integers . . . . . . . . . . . . . . .  11
       3.4.2.  Header Acknowledgement . . .  10
       5.1.2.  String Literals . . . . . . . . . . . .  11
     3.5.  Request and Push Streams . . . . . . .  10
     5.2.  QPACK Encoder Stream  . . . . . . . . .  11
       3.5.1.  Header Data Prefix . . . . . . . . .  11
       5.2.1.  Insert With Name Reference  . . . . . . . .  12
       3.5.2.  Instructions . . . . .  11
       5.2.2.  Insert Without Name Reference . . . . . . . . . . . .  11
       5.2.3.  Duplicate . . .  12
   4.  Encoding Strategies . . . . . . . . . . . . . . . . . . .  12
       5.2.4.  Dynamic Table Size Update . .  15
     4.1.  Single pass encoding . . . . . . . . . . . .  12
     5.3.  QPACK Decoder Stream  . . . . . .  15
     4.2.  Preventing Eviction Races . . . . . . . . . . . .  13
       5.3.1.  Table State Synchronize . . . .  15
     4.3.  Reference Tracking . . . . . . . . . . .  13
       5.3.2.  Header Acknowledgement  . . . . . . . .  15
       4.3.1.  Blocked Eviction . . . . . . .  14
       5.3.3.  Stream Cancellation . . . . . . . . . . .  16
       4.3.2.  Blocked Decoding . . . . . .  14
     5.4.  Request and Push Streams  . . . . . . . . . . . .  16
     4.4.  Speculative table updates . . . .  15
       5.4.1.  Header Data Prefix  . . . . . . . . . . . .  16
     4.5.  Sample One Pass Encoding Algorithm . . . . .  15
       5.4.2.  Instructions  . . . . . .  17
   5.  Security Considerations . . . . . . . . . . . . . .  16
   6.  Encoding Strategies . . . . .  18
   6.  IANA Considerations . . . . . . . . . . . . . . . .  19
     6.1.  Single Pass Encoding  . . . . .  18
   7.  References . . . . . . . . . . . . .  19
     6.2.  Preventing Eviction Races . . . . . . . . . . . .  18
     7.1.  Normative References . . . .  19
     6.3.  Reference Tracking  . . . . . . . . . . . . . .  18
     7.2.  Informative References . . . . .  19
       6.3.1.  Blocked Eviction  . . . . . . . . . . . .  18
     7.3.  URIs . . . . . .  20
       6.3.2.  Blocked Decoding  . . . . . . . . . . . . . . . . . .  20
     6.4.  Speculative table updates . .  19
   Acknowledgments . . . . . . . . . . . . . .  20
     6.5.  Sample One Pass Encoding Algorithm  . . . . . . . . . . .  19
   Change Log  20
   7.  Security Considerations . . . . . . . . . . . . . . . . . . .  22
   8.  IANA Considerations . . . . . . . .  19
     B.1.  Since draft-ietf-quic-qcram-00 . . . . . . . . . . . . .  19
   Authors' Addresses  22
     8.1.  Settings Registration . . . . . . . . . . . . . . . . . .  22
     8.2.  Stream Type Registration  . . . . .  20

1.  Introduction

   The . . . . . . . . . . .  22
   9.  References  . . . . . . . . . . . . . . . . . . . . . . . . .  22
     9.1.  Normative References  . . . . . . . . . . . . . . . . . .  22
     9.2.  Informative References  . . . . . . . . . . . . . . . . .  23
     9.3.  URIs  . . . . . . . . . . . . . . . . . . . . . . . . . .  23
   Appendix A.  Change Log . . . . . . . . . . . . . . . . . . . . .  23
     A.1.  Since draft-ietf-quic-qpack-00  . . . . . . . . . . . . .  23
     A.2.  Since draft-ietf-quic-qcram-00  . . . . . . . . . . . . .  24
   Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . .  24
   Authors' Addresses  . . . . . . . . . . . . . . . . . . . . . . .  25

1.  Introduction

   The QUIC transport protocol was designed from the outset to support
   HTTP semantics, and its design subsumes many of the features of
   HTTP/2.  HTTP/2 used HPACK ([RFC7541]) for header compression, but
   QUIC's stream multiplexing comes into some conflict with
   header compression. HPACK.  A
   key goal of the design of QUIC is to improve stream multiplexing
   relative to HTTP/2 by eliminating HoL (head of
   line) blocking, which can occur in HTTP/2.  HoL reducing head-of-line blocking.  If HPACK were
   used for HTTP/QUIC, it would induce head-of-line blocking can happen
   because all HTTP/2 streams are multiplexed onto due to
   built-in assumptions of a single TCP
   connection with its in-order semantics.  QUIC can maintain
   independence between streams because it implements core transport
   functionality in a fully stream-aware manner.  However, the HTTP/QUIC
   mapping is still subject to HoL blocking if HPACK is used directly.
   HPACK exploits multiplexing for greater compression, shrinking the
   representation of headers that have appeared earlier on the same
   connection.  In the context of QUIC, this imposes a vulnerability to
   HoL blocking (see Section 1.1). total ordering across frames on all
   streams.

   QUIC is described in [QUIC-TRANSPORT].  The HTTP/QUIC mapping is
   described in [QUIC-HTTP].  For a full description of HTTP/2, see
   [RFC7540].  The description of HPACK is [RFC7541], with important
   terminology in Section 1.3.

   QPACK modifies HPACK reuses core concepts from HPACK, but is redesigned to allow
   correctness in the presence of out-of-
   order out-of-order delivery, with
   flexibility for implementations to balance between resilience against HoL
   head-of-line blocking and optimal compression ratio.  The design
   goals are to closely approach the compression ratio of HPACK with
   substantially less head-of-line blocking under the same loss
   conditions.

2.  Header Tables

   Like HPACK, QPACK is intended to be a relatively non-intrusive extension uses two tables for associating header fields to
   HPACK;
   indexes.  The static table (see Section 2.1) is predefined and
   contains common header fields (some of them with an implementation should be easily shared within stacks
   supporting both HTTP/2 empty value).

   The dynamic table (see Section 2.2) built up over (TLS+)TCP the course of the
   connection and HTTP/QUIC.

1.1.  Head-of-Line Blocking can be used by the encoder to index header fields
   repeated in HPACK

   HPACK enables several types the encoded header lists.

   Unlike in HPACK, entries in the QPACK static and dynamic tables are
   addressed separately.  The following sections describe how entries in
   each table is addressed.

2.1.  Static Table

   The static table consists of a predefined static list of header representations, one
   fields, each of which
   also adds the header to has a fixed index over time.  Its entries are
   defined in Appendix A of [RFC7541].  Note that because HPACK did not
   use zero-based references, there is no value at index zero of the
   static table.

2.2.  Dynamic Table

   The dynamic table consists of a list of header values.  These
   values are then available for reuse fields maintained in subsequent header blocks
   simply
   first-in, first-out order.  The dynamic table is initially empty.
   Entries are added by referencing instructions on the Encoder Stream (see
   Section 5.2).

   Before a new entry number in is added to the table.

   If dynamic table, entries are evicted
   from the packet containing a header is lost, that stream cannot
   complete header processing end of the dynamic table until the packet is retransmitted.  This
   is unavoidable.  However, other streams which rely on size of the state
   created by that packet _also_ cannot make progress.  This dynamic table
   is the
   problem which QUIC solves in general, but which is reintroduced by
   HPACK when the loss includes a HEADERS frame.

1.2.  Avoiding Head-of-Line Blocking in HTTP/QUIC

   Because QUIC does not guarantee order between data on different
   streams, a header block might reference an less than or equal to (maximum size - new entry in the dynamic table
   that has not yet been received.

   Each header block contains a Largest Reference (see Section 3.5.1)
   which identifies size) or until the
   table state necessary for decoding. is empty.

   If the
   greatest absolute index in size of the dynamic table new entry is less than or equal to the value
   of the Largest Reference, the stream maximum
   size, that entry is considered "blocked."  While
   blocked, header field data should remain in the blocked stream's flow
   control window.  When added to the Largest Reference table.  It is zero, the frame
   contains no references an error to attempt to
   add an entry that is larger than the dynamic table and can always maximum size; this MUST be
   processed immediately.
   treated as a connection error of type
   "HTTP_QPACK_DECOMPRESSION_FAILED".

   A stream becomes unblocked when the greatest
   absolute index new entry can reference an entry in the dynamic table becomes greater than or equal that will be
   evicted when adding this new entry into the dynamic table.
   Implementations are cautioned to avoid deleting the Largest Reference for all header blocks referenced name
   if the decoder has started
   reading referenced entry is evicted from the stream.

   A decoder dynamic table prior to
   inserting the new entry.

   The dynamic table can permit contain duplicate entries (i.e., entries with
   the possibility of blocked streams same name and same value).  Therefore, duplicate entries MUST NOT
   be treated as an error by setting
   SETTINGS_QPACK_BLOCKED_STREAMS to a non-zero value.  This setting
   specifies an upper bound on decoder.

   The encoder decides how to update the number of streams which dynamic table and as such can be
   blocked.

   An
   control how much memory is used by the dynamic table.  To limit the
   memory requirements of the decoder, the dynamic table size is
   strictly bounded.

   The decoder determines the maximum size that the encoder can decide whether to risk having a stream become blocked.
   If is permitted by
   to use for the dynamic table.  In HTTP/QUIC, this value is determined
   by the SETTINGS_HEADER_TABLE_SIZE setting (see Section 4.2.5.2 of SETTINGS_QPACK_BLOCKED_STREAMS,
   compression efficiency
   [QUIC-HTTP]).

   An encoder can be improved choose to use less capacity than this maximum size
   (see Section 5.2.4), but the chosen size MUST stay lower than or
   equal to the maximum set by referencing the decoder.  Whenever the maximum size
   for the dynamic table is reduced, entries that are still in transit, but if there is loss or reordering evicted from the stream can become blocked at end of
   the decoder.  An encoder avoids dynamic table until the
   risk size of blocking by only referencing the dynamic table is less than or
   equal to the maximum size.

   This mechanism can be used to completely clear entries which have
   been acknowledged, but this means using literals.  Since literals
   make from the header block larger, this
   dynamic table by setting a maximum size of 0, which can result in subsequently
   be restored.

2.2.1.  Absolute and Relative Indexing

   Each entry possesses both an absolute index which is fixed for the encoder becoming
   blocked
   lifetime of that entry and a relative index which changes over time
   based on congestion or flow control limits.

   An encoder MUST limit the number context of streams which could become
   blocked to the value reference.  The first entry inserted has
   an absolute index of SETTINGS_QPACK_BLOCKED_STREAMS "1"; indices increase sequentially with each
   insertion.

   The relative index begins at all times.
   Note that zero and increases in the decoder might opposite
   direction from the absolute index.  Determining which entry has a
   relative index of "0" depends on the context of the reference.

   On the control stream, a relative index of "0" always refers to the
   most recently inserted value in the dynamic table.  Note that this
   means the entry referenced by a given relative index will change
   while interpreting instructions on the encoder stream.

       +---+---------------+-----------+
       | n |      ...      |   d + 1   |  Absolute Index
       + - +---------------+ - - - - - +
       | 0 |      ...      | n - d - 1 |  Relative Index
       +---+---------------+-----------+
         ^                     |
         |                     V
   Insertion Point         Dropping Point

   n = count of entries inserted
   d = count of entries dropped

              Example Dynamic Table Indexing - Control Stream

   Because frames from request streams can be delivered out of order
   with instructions on the control stream, relative indices are
   relative to the Base Index at the beginning of the header block (see
   Section 5.4.1).  The Base Index is an absolute index.  When
   interpreting the rest of the frame, the entry identified by Base
   Index has a relative index of zero.  The relative indices of entries
   do not change while interpreting headers on a request or push stream.

                Base Index
                    |
                    V
       +---+-----+-----+-----+-------+
       | n | n-1 | n-2 | ... |  d+1  |  Absolute Index
       +---+-----+  -  +-----+   -   +
                 |  0  | ... | n-d-3 |  Relative Index
                 +-----+-----+-------+

   n = count of entries inserted
   d = count of entries dropped

              Example Dynamic Table Indexing - Request Stream

2.2.2.  Post-Base Indexing

   A header block on the request stream can reference entries added
   after the entry identified by the Base Index.  This allows an encoder
   to process a header block in a single pass and include references to
   entries added while processing this (or other) header blocks.  Newly
   added entries are referenced using Post-Base instructions.  Indices
   for Post-Base instructions increase in the same direction as absolute
   indices, but the zero value is one higher than the Base Index.

                Base Index
                    |
                    V
       +---+-----+-----+-----+-----+
       | n | n-1 | n-2 | ... | d+1 |  Absolute Index
       +---+-----+-----+-----+-----+
       | 1 |  0  |                    Post-Base Index
       +---+-----+

   n = count of entries inserted
   d = count of entries dropped

               Dynamic Table Indexing - Post-Base References

   If the decoder encounters a reference to an entry which has already
   been dropped from the table or which is greater than the declared
   Largest Reference (see Section 5.4.1), this MUST be treated as a
   stream error of type "HTTP_QPACK_DECOMPRESSION_FAILED" error code.
   If this reference occurs on the control stream, this MUST be treated
   as a session error.

2.3.  Avoiding Head-of-Line Blocking in HTTP/QUIC

   Because QUIC does not actually become blocked guarantee order between data on every
   stream different
   streams, a header block might reference an entry in the dynamic table
   that has not yet been received.

   Each header block contains a Largest Reference which risks becoming blocked. identifies the
   table state necessary for decoding.  If the greatest absolute index
   in the dynamic table is less than the value of the Largest Reference,
   the stream is considered "blocked."  While blocked, header field data
   should remain in the blocked stream's flow control window.  When the
   Largest Reference is zero, the frame contains no references to the
   dynamic table and can always be processed immediately.  A stream
   becomes unblocked when the greatest absolute index in the dynamic
   table becomes greater than or equal to the Largest Reference for all
   header blocks the decoder has started reading from the stream.  If a
   decoder encounters more
   blocked streams than it promised a header block where the actual largest reference
   is not equal to support, the largest reference declared in the prefix, it SHOULD MAY
   treat this as a stream error of type HTTP_QPACK_DECOMPRESSION_FAILED.

2.  Conventions and Definitions

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in BCP
   14 [RFC2119] [RFC8174] when, and only when, they appear in all
   capitals, as shown here.

   Definitions of terms that are used in this document:

   Header:

   A name-value pair sent as part of an HTTP message.

   Header set:  The full collection decoder can permit the possibility of headers associated with blocked streams by setting
   SETTINGS_QPACK_BLOCKED_STREAMS to a non-zero value (see Section 4).
   This setting specifies an HTTP
      message.

   Header block:  The compressed representation upper bound on the number of a header set.

   Encoder:  An implementation streams which transforms a header set into a
      header block.

   Decoder:
   can be blocked.

   An implementation which transforms a header block into a
      header set.

   QPACK is encoder can decide whether to risk having a name, not an acronym.

2.1.  Notational Conventions

   Diagrams use stream become blocked.
   If permitted by the format described in Section 3.1 value of [RFC2360], with
   the following additional conventions:

   x (A)  Indicates SETTINGS_QPACK_BLOCKED_STREAMS,
   compression efficiency can be improved by referencing dynamic table
   entries that x are still in transit, but if there is A bits long

   x (A+)  Indicates that x uses loss or reordering
   the stream can become blocked at the decoder.  An encoder avoids the
   risk of blocking by only referencing dynamic table entries which have
   been acknowledged, but this means using literals.  Since literals
   make the prefixed integer encoding defined header block larger, this can result in Section 5.1 the encoder becoming
   blocked on congestion or flow control limits.

   An encoder MUST limit the number of [RFC7541], beginning with an A-bit prefix.

   x ...  Indicates that x is variable-length and extends streams which could become
   blocked to the end value of SETTINGS_QPACK_BLOCKED_STREAMS at all times.
   Note that the region.

3.  Wire Format

   QPACK instructions occur in three locations, each of which uses a
   separate instruction space:

   o  Table updates are carried by a unidirectional decoder might not actually become blocked on every
   stream from encoder which risks becoming blocked.  If the decoder encounters more
   blocked streams than it promised to decoder.  Instructions on support, it SHOULD treat this as
   a stream modify error of type HTTP_QPACK_DECOMPRESSION_FAILED.

2.3.1.  State Synchronization

   The decoder stream signals key events at the dynamic table
      state without generating output decoder that permit the
   encoder to any particular request. track the decoder's state.  These events are:

   o  Acknowledgements of table modifications and header  Successful processing are
      carried by of a unidirectional stream from decoder to encoder. header block

   o  Finally, the contents  Abandonment of HEADERS and PUSH_PROMISE frames on
      request streams reference the QPACK table state.

   This section describes the instructions which are possible on each a stream type.

   All table updates occur on the control stream.  Request streams only
   carry which might have remaining header blocks that do not modify the state of the table.

3.1.  Primitives

   The prefixed integer from Section 5.1

   o  Receipt of [RFC7541] is used heavily
   throughout this document.  The string literal, defined by Section 5.2 new dynamic table entries

   Regardless of [RFC7541], is used with whether a header block contained blocking references,
   the knowledge that it was processed successfully permits the following modification.

   HPACK defines string literals encoder
   to begin on a byte boundary.  They
   begin with avoid evicting entries while references remain outstanding; see
   Section 6.3.1.  When a single flag (indicating whether the string stream is Huffman-
   coded), followed by reset or abandoned, the Length encoded as indication
   that these header blocks will never be processed serves a 7-bit prefix integer, and
   finally Length octets of data.

   QPACK permits strings similar
   function; see Section 5.3.3.

   For the encoder to begin other than on identify which dynamic table entries can be safely
   used without a byte boundary.  An
   "N-bit prefix string literal" begins with stream becoming blocked, the same Huffman flag,
   followed by encoder tracks the length encoded as an (N-1)-bit prefix integer.  The
   remainder
   absolute index of the string literal is unmodified.

   A string literal without a prefix length noted is an 8-bit prefix
   string literal and follows decoder's Largest Known Received entry.

   When blocking references are permitted, the definitions in [RFC7541] without
   modification.

3.2.  Indexing

   Entries in encoder uses
   acknowledgement of header blocks to identify the QPACK static and Largest Known
   Received index, as described in Section 5.3.2.

   To acknowledge dynamic tables table entries which are addressed
   separately.

   Entries in not referenced by
   header blocks, for example because the static table encoder or the decoder have
   chosen not to risk blocked streams, the same indices at all times. decoder sends a Table State
   Synchronize instruction (see Section 5.3.1).

3.  Conventions and Definitions

   The
   static table is defined key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in Appendix this document are to be interpreted as described in BCP
   14 [RFC2119] [RFC8174] when, and only when, they appear in all
   capitals, as shown here.

   Definitions of terms that are used in this document:

   Header:  A name-value pair sent as part of [RFC7541].  Note that
   because HPACK did not use zero-based references, there is no value at
   index zero an HTTP message.

   Header set:  The full collection of the static table.

   Entries are inserted into the dynamic table over time.  Each entry
   possesses both headers associated with an absolute index which is fixed for the lifetime HTTP
      message.

   Header block:  The compressed representation of
   that entry and a relative index header set.

   Encoder:  An implementation which changes over time based on the
   context of the reference.  The first entry inserted has an absolute
   index of "1"; indices increase sequentially with each insertion.

   On the control stream, transforms a relative index of "0" always refers to header set into a
      header block.

   Decoder:  An implementation which transforms a header block into a
      header set.

   QPACK is a name, not an acronym.

3.1.  Notational Conventions

   Diagrams use the
   most recently inserted value format described in Section 3.1 of [RFC2360], with
   the dynamic table.  Note following additional conventions:

   x (A)  Indicates that this
   means x is A bits long

   x (A+)  Indicates that x uses the entry referenced by a given relative index can change while
   interpreting a HEADERS frame as new entries are inserted.

       +---+---------------+-------+
       | n |      ...      | d + 1 |  Absolute Index
       + - +---------------+   -   +
       | 0 |      ...      | n-d-1 |  Relative Index
       +---+---------------+-------+
         ^                     |
         |                     V
   Insertion Point         Dropping Point

   n = count of entries inserted
   d = count of entries dropped

              Example Dynamic Table Indexing - Control Stream

   Because frames from request streams can be delivered out prefixed integer encoding defined
      in Section 5.1 of order [RFC7541], beginning with instructions on the control stream, relative indices are
   relative an A-bit prefix.

   x ...  Indicates that x is variable-length and extends to the Base Index at the beginning end of
      the header block (see region.

4.  Configuration

   QPACK defines two settings which are included in the HTTP/QUIC
   SETTINGS frame.

   SETTINGS_HEADER_TABLE_SIZE (0x1):  An integer with a maximum value of
      2^30 - 1.  The default value is 4,096 bytes.  See (TODO: reference
      PR#1357) for usage.

   SETTINGS_QPACK_BLOCKED_STREAMS (0x7):  An integer with a maximum
      value of 2^16 - 1.  The default value is 100.  See Section 3.5.1). 2.3.

5.  Wire Format

   QPACK instructions occur in three locations, each of which uses a
   separate instruction space:

   o  The Base Index encoder stream is the absolute index a unidirectional stream of the entry type "0x48"
      (ASCII 'H') which has carries table updates from encoder to decoder.
      Instructions on this stream modify the relative index dynamic table state without
      generating output to any particular request.

   o  The decoder stream is a unidirectional stream of zero when interpreting type "0x68"
      (ASCII 'h') which carries acknowledgements of table modifications
      and header processing from decoder to encoder.

   o  Finally, the frame.
   The relative indices contents of entries do not change while interpreting
   headers HEADERS and PUSH_PROMISE frames on a
      request or streams and push stream.

                Base Index
                    |
                    V
       +---+-----+-----+-----+-------+
       | n | n-1 | n-2 | ... |  d+1  |  Absolute Index
       +---+-----+  -  +-----+   -   +
                 |  0  | ... | n-d-3 |  Relative Index
                 +-----+-----+-------+

   n = count streams reference the QPACK table state.

   There MUST be exactly one of entries inserted
   d = count each unidirectional stream type in each
   direction.  Receipt of entries dropped

              Example Dynamic Table Indexing - Request Stream

   Entries with an absolute index greater than a frame's Base Index can second instance of either stream type MUST
   be treated as a connection error of HTTP_WRONG_STREAM_COUNT.  Closure
   of either unidirectional stream MUST be referenced using specific Post-Base instructions.  The relative
   indices treated as a connection error
   of Post-Base references count up type HTTP_CLOSED_CRITICAL_STREAM.

   This section describes the instructions which are possible on each
   stream type.

   All table updates occur on the encoder stream.  Request streams and
   push streams only carry header blocks that do not modify the state of
   the table.

5.1.  Primitives

5.1.1.  Prefixed Integers

   The prefixed integer from Base Index.

                Base Index
                    |
                    V
       +---+-----+-----+-----+-----+
       | n | n-1 | n-2 | ... | d+1 |  Absolute Index
       +---+-----+-----+-----+-----+
       | 1 |  0  |                    Post-Base Index
       +---+-----+

   n = count Section 5.1 of entries inserted
   d = count [RFC7541] is used heavily
   throughout this document.  The format from [RFC7541] is used
   unmodified.

5.1.2.  String Literals

   The string literal defined by Section 5.2 of entries dropped

               Dynamic Table Indexing - Post-Base References

   If [RFC7541] is also used
   throughout.  This string format includes optional Huffman encoding.

   HPACK defines string literals to begin on a byte boundary.  They
   begin with a single flag (indicating whether the decoder encounters string is Huffman-
   coded), followed by the Length encoded as a reference to an entry which has already
   been dropped from 7-bit prefix integer, and
   finally Length octets of data.  When Huffman encoding is enabled, the
   Huffman table or which from Appendix B of [RFC7541] is greater used without
   modification.

   This document expands the definition of string literals and permits
   them to begin other than on a byte boundary.  An "N-bit prefix string
   literal" begins with the declared
   Largest Reference, this MUST be treated same Huffman flag, followed by the length
   encoded as a stream error an (N-1)-bit prefix integer.  The remainder of type
   "HTTP_QPACK_DECOMPRESSION_FAILED" error code.  If this reference
   occurs on the control stream, this MUST be treated as string
   literal is unmodified.

   A string literal without a session
   error.

3.3. prefix length noted is an 8-bit prefix
   string literal and follows the definitions in [RFC7541] without
   modification.

5.2.  QPACK Encoder Stream

   Table updates can add a table entry, possibly using existing entries
   to avoid transmitting redundant information.  The name can be
   transmitted as a reference to an existing entry in the static or the
   dynamic table or as a string literal.  For entries which already
   exist in the dynamic table, the full entry can also be used by
   reference, creating a duplicate entry.

   Each set

   The contents of the encoder instructions is prefaced by its length, encoded
   as a variable length integer with stream are an 8-bit prefix.  Instructions MUST
   NOT span more than one block.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      |       Block Length (8+)       |
      +-------------------------------+
      |     Instruction Block (*)   ...
      +-------------------------------+

                         Encoder instruction block

3.3.1. unframed sequence of the
   following instructions.

5.2.1.  Insert With Name Reference

   An addition to the header table where the header field name matches
   the header field name of an entry stored in the static table or the
   dynamic table starts with the '1' one-bit pattern.  The "S" bit
   indicates whether the reference is to the static (S=1) or dynamic
   (S=0) table.  The header field name is represented using the relative
   index of that entry, which is represented as an integer with a 6-bit
   prefix (see Section 5.1 of [RFC7541]).

   The header name reference is followed by the header field value
   represented as a string literal (see Section 5.2 of [RFC7541]).

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 1 | S |    Name Index (6+)    |
      +---+---+-----------------------+
      | H |     Value Length (7+)     |
      +---+---------------------------+
      | Value String (Length octets)  |
      +-------------------------------+

                    Insert Header Field -- Indexed Name

3.3.2.

5.2.2.  Insert Without Name Reference

   An addition to the header table where both the header field name and
   the header field value are represented as string literals (see
   Section 3.1) 5.1) starts with the '01' two-bit pattern.

   The name is represented as a 6-bit prefix string literal, while the
   value is represented as an 8-bit prefix string literal.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 0 | 1 | H | Name Length (5+)  |
      +---+---+---+-------------------+
      |  Name String (Length octets)  |
      +---+---------------------------+
      | H |     Value Length (7+)     |
      +---+---------------------------+
      | Value String (Length octets)  |
      +-------------------------------+

                      Insert Header Field -- New Name

3.3.3.

5.2.3.  Duplicate

   Duplication of an existing entry in the dynamic table starts with the
   '000' three-bit pattern.  The relative index of the existing entry is
   represented as an integer with a 5-bit prefix.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 0 | 0 | 0 |    Index (5+)     |
      +---+---+---+-------------------+

                            Figure 1: Duplicate

   The existing entry is re-inserted into the dynamic table without
   resending either the name or the value.  This is useful to mitigate
   the eviction of older entries which are frequently referenced, both
   to avoid the need to resend the header and to avoid the entry in the
   table blocking the ability to insert new headers.

3.3.4.

5.2.4.  Dynamic Table Size Update

   An encoder informs the decoder of a change to the size of the dynamic
   table using an instruction which begins with the '001' three-bit
   pattern.  The new maximum table size is represented as an integer
   with a 5-bit prefix (see Section 5.1 of [RFC7541]).

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 1 |   Max size (5+)   |
   +---+---+---+-------------------+

                Figure 2: Maximum Dynamic Table Size Change

   The new maximum size MUST be lower than or equal to the limit
   determined by the protocol using QPACK.  A value that exceeds this
   limit MUST be treated as a decoding error.  In HTTP/QUIC, this limit
   is the value of the SETTINGS_HEADER_TABLE_SIZE parameter (see
   [QUIC-HTTP])
   Section 4) received from the decoder.

   Reducing the maximum size of the dynamic table can cause entries to
   be evicted (see Section 4.3 of [RFC7541]).  This MUST NOT cause the
   eviction of entries with outstanding references (see Section 4.3).

3.4. 6.3).
   Changing the size of the dynamic table is not acknowledged as this
   instruction does not insert an entry.

5.3.  QPACK Decoder Stream

   The decoder stream carries information used to ensure consistency of
   the dynamic table.  Information is sent from the QPACK decoder to the
   QPACK encoder; that is, the server informs the client about the
   processing of the client's header blocks and table updates, and the
   client informs the server about the processing of the server's header
   blocks and table updates.

3.4.1.

   The contents of the decoder stream are an unframed sequence of the
   following instructions.

5.3.1.  Table State Synchronize

   The Table State Synchronize instruction begins with the '00' two-bit
   pattern.  The instruction specifies the total number of dynamic table
   inserts and duplications since the last Table State Synchronize or
   Header Acknowledgement that increased the Largest Known Received
   dynamic table entry.  This is encoded as a 6-bit prefix integer.  The
   encoder uses this value to determine which table entries might cause
   a stream to become blocked, as described in Section 2.3.1.

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 |   Insert Count (6+)   |
   +---+---+-----------------------+

                     Figure 3: Table State Synchronize

   A decoder chooses when to emit Table State Synchronize instructions.
   Emitting a Table State Synchronize after adding each new dynamic
   table entry will provide the most timely feedback to the encoder, but
   could be redundant with other decoder feedback.  By delaying a
   Table State Synchronize, a decoder might be able to coalesce multiple
   Table State Synchronize instructions, or replace them entirely with
   Header Acknowledgements.  However, delaying too long may lead to
   compression inefficiencies if the encoder waits for an entry to be
   acknowledged before using it.

5.3.2.  Header Acknowledgement

   After processing a set of instructions header block on the encoder a request or push stream, the
   decoder will emit emits a Table State Synchronize Header Acknowledgement instruction on the decoder
   stream.  The instruction begins with the '1' one-bit pattern.
   The instruction specifies the total number of dynamic table inserts pattern and duplications since
   includes the last Table State Synchronize, request stream's stream ID, encoded as a 7-bit prefix
   integer.  The  It is used by the peer's QPACK encoder uses this value to determine which
   table entries are vulnerable know when it is
   safe to head-of-line blocking.  A decoder MAY
   coalesce evict an entry.

   The same Stream ID can be identified multiple synchronization updates into times, as multiple
   header blocks can be sent on a single update. stream in the case of
   intermediate responses, trailers, and pushed requests.  Since header
   frames on each stream are received and processed in order, this gives
   the encoder precise feedback on which header blocks within a stream
   have been fully processed.

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 1 |     Insert Count      Stream ID (7+)       |
   +---+---------------------------+

                     Figure 3: Table Size Synchronize

3.4.2. 4: Header Acknowledgement

   After processing

   When blocking references are permitted, the encoder uses
   acknowledgement of header blocks to update the Largest Known Received
   index.  If a header block on a request or push stream, was potentially blocking, the
   acknowledgement implies that the decoder emits has received all dynamic
   table state necessary to process the header block.  If the Largest
   Reference of an acknowledged header block was greater than the
   encoder's current Largest Known Received index, the block's Largest
   Reference becomes the new Largest Known Received.

5.3.3.  Stream Cancellation

   A stream that is reset might have multiple outstanding header blocks.
   A decoder that receives a stream reset before the end of a Header Acknowledgement stream
   generates a Stream Cancellation instruction on the decoder stream.
   Similarly, a decoder that abandons reading of a stream needs to
   signal this using the Stream Cancellation instruction.  This signals
   to the encoder that all references to the dynamic table on that
   stream are no longer outstanding.

   An encoder cannot infer from this instruction that any updates to the
   dynamic table have been received.

   The instruction begins with the '0' one-bit pattern and '01' two-bit pattern.  The
   instruction includes the stream ID of the affected stream - a request stream's
   or push stream ID, - encoded as a 7-bit 6-bit prefix integer.  It is used by the peer's QPACK encoder to know when it is
   safe to evict an entry.

   The same Stream ID can be identified multiple times, as multiple
   header blocks can be sent on a single stream in the case of
   intermediate responses, trailers, and pushed requests.  Since header
   frames on each stream are received and processed in order, this gives
   the encoder precise feedback on which header blocks within a stream
   have been fully processed.

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 1 |     Stream ID (7+) (6+)    |
   +---+---------------------------+
   +---+---+-----------------------+

                       Figure 4: Header Acknowledgement

3.5. 5: Stream Cancellation

5.4.  Request and Push Streams

   HEADERS and PUSH_PROMISE frames on request and push streams reference
   the dynamic table in a particular state without modifying it.  Frames
   on these streams emit the headers for an HTTP request or response.

3.5.1.

5.4.1.  Header Data Prefix

   Header data is prefixed with two integers, "Largest Reference" and
   "Base Index".

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   |     Largest Reference (8+)    |
   +---+---------------------------+
   | S |   Delta Base Index (7+)   |
   +---+---------------------------+
   |      Compressed Headers     ...
   +-------------------------------+

                          Figure 5: 6: Frame Payload

   "Largest Reference" identifies the largest absolute dynamic index
   referenced in the block.  Blocking decoders use the Largest Reference
   to determine when it is safe to process the rest of the block.

   "Base Index" is used to resolve references in the dynamic table as
   described in Section 3.2. 2.2.1.

   To save space, Base Index is encoded relative to Largest Reference
   using a one-bit sign flag. and the "Delta Base Index" value.  A sign bit of
   0 indicates that the Base Index has an absolute index that is greater
   than or equal to the Largest Reference; the value of Delta Base Index
   is added to the Largest Reference to determine the absolute value of
   the Base Index.  A sign bit of 1 indicates that the Base Index is
   less than the Largest Reference.  That is:

      if sign == 0:
         baseIndex = largestReference + deltaBaseIndex
      else:
         baseIndex = largestReference - deltaBaseIndex

   A single-pass encoder is expected to determine the absolute value of
   Base Index before encoding a header block.  If the encoder inserted
   entries to in the dynamic table while the encoding the header block, Largest
   Reference will be greater than Base Index, so
   deltaBaseIndex will be the encoded difference
   is negative and encoded with S=1. the sign bit is set to 1.  If the header block did
   not reference the most recent entry in the table and did not insert
   any new entries, Largest Reference Base Index will be less greater than Base
   Index, the Largest
   Reference, so deltaBaseIndex the delta will be positive and encoded with S=0. the sign bit is set to
   0.

   An encoder that produces table updates before encoding a header block
   might set Largest Reference and Base Index to the same value.  When
   Largest Reference and Base Index are equal, deltaBaseIndex the Delta Base Index is 0 and
   encoded with S=0.

3.5.2. a zero sign bit.  A sign bit set to 1 when the Delta
   Base Index is 0 MUST be treated as a decoder error.

   A header block that does not reference the dynamic table can use any
   value for Base Index; setting both Largest Reference and Base Index
   to zero is the most efficient encoding.

5.4.2.  Instructions

3.5.2.1.

5.4.2.1.  Indexed Header Field

   An indexed header field representation identifies an entry in either
   the static table or the dynamic table and causes that header field to
   be added to the decoded header list, as described in Section 3.2 of
   [RFC7541].

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 1 | S |      Index (6+)       |
   +---+---+-----------------------+

                           Indexed Header Field

   If the entry is in the static table, or in the dynamic table with an
   absolute index less than or equal to Base Index, this representation
   starts with the '1' 1-bit pattern, followed by the "S" bit indicating
   whether the reference is into the static (S=1) or dynamic (S=0)
   table.  Finally, the relative index of the matching header field is
   represented as an integer with a 6-bit prefix (see Section 5.1 of
   [RFC7541]).

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 1 | 0 | 0 |  Index (4+)   |
   +---+---+-----------------------+

5.4.2.2.  Indexed Header Field With Post-Base Index

   If the entry is in the dynamic table with an absolute index greater
   than Base Index, the representation starts with the '0100' '0001' 4-bit
   pattern, followed by the post-base index (see Section 3.2) 2.2.1) of the
   matching header field, represented as an integer with a 4-bit prefix
   (see Section 5.1 of [RFC7541]).

3.5.2.2.

     0   1   2   3   4   5   6   7
   +---+---+---+---+---+---+---+---+
   | 0 | 0 | 0 | 1 |  Index (4+)   |
   +---+---+---+---+---------------+

                 Indexed Header Field with Post-Base Index

5.4.2.3.  Literal Header Field With Name Reference

   A literal header field with a name reference represents a header
   where the header field name matches the header field name of an entry
   stored in the static table or the dynamic table.

   If the entry is in the static table, or in the dynamic table with an
   absolute index less than or equal to Base Index, this representation
   starts with the '00' '01' two-bit pattern.  If the entry is in the dynamic
   table with an absolute index greater than Base Index, the
   representation starts with the '0101' '0000' four-bit pattern.

   The following bit, 'N', indicates whether an intermediary is
   permitted to add this header to the dynamic header table on
   subsequent hops.  When the 'N' bit is set, the encoded header MUST
   always be encoded with a literal representation.  In particular, when
   a peer sends a header field that it received represented as a literal
   header field with the 'N' bit set, it MUST use a literal
   representation to forward this header field.  This bit is intended
   for protecting header field values that are not to be put at risk by
   compressing them (see Section 7.1 of [RFC7541] for more details).

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 0 | 0 1 | N | S |Name Index (4+)|
      +---+---+-----------------------+
      +---+---+---+---+---------------+
      | H |     Value Length (7+)     |
      +---+---------------------------+
      | Value String (Length octets)  |
      +-------------------------------+

                 Literal Header Field With Name Reference

   For entries in the static table or in the dynamic table with an
   absolute index less than or equal to Base Index, the header field
   name is represented using the relative index of that entry, which is
   represented as an integer with a 4-bit prefix (see Section 5.1 of
   [RFC7541]).  The "S" bit indicates whether the reference is to the
   static (S=1) or dynamic (S=0) table.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 0 | 1 | 0 | 1 | N |NameIdx(3+)|
      +---+---+-----------------------+
      | H |     Value Length (7+)     |
      +---+---------------------------+
      | Value String (Length octets)  |
      +-------------------------------+

5.4.2.4.  Literal Header Field With Post-Base Name Reference

   For entries in the dynamic table with an absolute index greater than
   Base Index, the header field name is represented using the post-base
   index of that entry (see Section 3.2) 2.2.1) encoded as an integer with a
   3-bit prefix.

3.5.2.3.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 0 | 0 | 0 | 0 | N |NameIdx(3+)|
      +---+---+---+---+---+-----------+
      | H |     Value Length (7+)     |
      +---+---------------------------+
      | Value String (Length octets)  |
      +-------------------------------+

            Literal Header Field With Post-Base Name Reference

5.4.2.5.  Literal Header Field Without Name Reference

   An addition to the header table where both the header field name and
   the header field value are represented as string literals (see
   Section 3.1) 5.1) starts with the '011' '001' three-bit pattern.

   The fourth bit, 'N', indicates whether an intermediary is permitted
   to add this header to the dynamic header table on subsequent hops.
   When the 'N' bit is set, the encoded header MUST always be encoded
   with a literal representation.  In particular, when a peer sends a
   header field that it received represented as a literal header field
   with the 'N' bit set, it MUST use a literal representation to forward
   this header field.  This bit is intended for protecting header field
   values that are not to be put at risk by compressing them (see
   Section 7.1 of [RFC7541] for more details).

   The name is represented as a 4-bit prefix string literal, while the
   value is represented as an 8-bit prefix string literal.

        0   1   2   3   4   5   6   7
      +---+---+---+---+---+---+---+---+
      | 0 | 1 0 | 1 | N | H |NameLen(3+)|
      +---+---+---+-------------------+
      +---+---+---+---+---+-----------+
      |  Name String (Length octets)  |
      +---+---------------------------+
      | H |     Value Length (7+)     |
      +---+---------------------------+
      | Value String (Length octets)  |
      +-------------------------------+

                Literal Header Field Without Name Reference

4.

6.  Encoding Strategies

4.1.

6.1.  Single pass encoding Pass Encoding

   An encoder making a single pass over a list of headers must choose
   Base Index before knowing Largest Reference.  When trying to
   reference a header inserted to the table after encoding has begun,
   the entry is encoded with different instructions that tell the
   decoder to use an absolute index greater than the Base Index.

4.2.

6.2.  Preventing Eviction Races

   Due to out-of-order arrival, QPACK's eviction algorithm requires
   changes (relative to HPACK) to avoid the possibility that an indexed
   representation is decoded after the referenced entry has already been
   evicted.  QPACK employs a two-phase eviction algorithm, in which the
   encoder will not evict entries that have outstanding (unacknowledged)
   references.

4.3.

6.3.  Reference Tracking

   An encoder MUST ensure that a header block which references a dynamic
   table entry is not received by the decoder after the referenced entry
   has already been evicted.  An encoder also respects the limit set by
   the decoder on the number of streams that are allowed to become
   blocked.  Even if the decoder is willing to tolerate blocked streams,
   the encoder might choose to avoid them in certain cases.

   In order to enable this, the encoder will need to track outstanding
   (unacknowledged) header blocks and table updates using feedback
   received from the decoder.

4.3.1.

6.3.1.  Blocked Eviction

   The encoder MUST NOT permit an entry to be evicted while a reference
   to that entry remains unacknowledged.  If a new header to be inserted
   into the dynamic table would cause the eviction of such an entry, the
   encoder MUST NOT emit the insert instruction until the reference has
   been processed by the decoder and acknowledged.

   The encoder can emit a literal representation for the new header in
   order to avoid encoding delays, and MAY insert the header into the
   table later if desired.

   To ensure that the blocked eviction case is rare, references to the
   oldest entries in the dynamic table SHOULD be avoided.  When one of
   the oldest entries in the table is still actively used for
   references, the encoder SHOULD emit an Duplicate representation
   instead (see Section 3.3.3).

4.3.2. 5.2.3).

6.3.2.  Blocked Decoding

   For header blocks encoded in non-blocking mode, the encoder needs to
   forego indexed representations that refer to table updates which have
   not yet been acknowledged with Section 3.4. 5.3.  Since all table updates
   are processed in sequence on the control stream, an index into the
   dynamic table is sufficient to track which entries have been
   acknowledged.

   To track blocked streams, the necessary Base Index value for each
   stream can be used.  Whenever the decoder processes a table update,
   it can begin decoding any blocked streams that now have their
   dependencies satisfied.

4.4.

6.4.  Speculative table updates

   Implementations can _speculatively_ send header frames on the HTTP
   Control Streams which are not needed for any current HTTP request or
   response.  Such headers could be used strategically to improve
   performance.  For instance, the encoder might decide to _refresh_ by
   sending Duplicate representations for popular header fields
   (Section 3.3.3), 5.2.3), ensuring they have small indices and hence minimal
   size on the wire.

4.5.

6.5.  Sample One Pass Encoding Algorithm

   Pseudo-code for single pass encoding, excluding handling of
   duplicates, non-blocking mode, and reference tracking.

   baseIndex = dynamicTable.baseIndex
   largestReference = 0
   for header in headers:
     staticIdx = staticTable.getIndex(header)
     if staticIdx:
       encodeIndexReference(streamBuffer, staticIdx)
       continue

     dynamicIdx = dynamicTable.getIndex(header)
     if !dynamicIdx:
       # No matching entry.  Either insert+index or encode literal
       nameIdx = getNameIndex(header)
       if shouldIndex(header) and dynamicTable.canIndex(header):
         encodeLiteralWithIncrementalIndex(controlBuffer, nameIdx,
                                           header)
         dynamicTable.add(header)
         dynamicIdx = dynamicTable.baseIndex

     if !dynamicIdx:
       # Couldn't index it, literal
       if nameIdx <= staticTable.size:
         encodeLiteral(streamBuffer, nameIndex, header)
       else:
         # encode literal, possibly with nameIdx above baseIndex
         encodeDynamicLiteral(streamBuffer, nameIndex, baseIndex,
                              header)
         largestReference = max(largestReference,
                                dynamicTable.toAbsolute(nameIdx))
     else:
       # Dynamic index reference
       assert(dynamicIdx)
       largestReference = max(largestReference, dynamicIdx)
       # Encode dynamicIdx, possibly with dynamicIdx above baseIndex
       encodeDynamicIndexReference(streamBuffer, dynamicIdx,
                                   baseIndex)

   # encode the prefix
   encodeInteger(prefixBuffer, 0x00, largestReference, 8)
   delta = largestReference -
   if baseIndex
   sign = delta > 0 ? 0x80 : 0 >= largestReference:
     encodeInteger(prefixBuffer, sign, delta, 0, baseIndex - largestReference, 7)
   else:
     encodeInteger(prefixBuffer, 0x80,
                   largestReference  - baseIndex, 7)

   return controlBuffer, prefixBuffer + streamBuffer

5.

7.  Security Considerations

   TBD.

6.

8.  IANA Considerations

   None.

7.

8.1.  Settings Registration

   This document creates two new settings in the "HTTP/QUIC Settings"
   registry established in [QUIC-HTTP].

   The entries in the following table are registered by this document.

             +-----------------------+------+---------------+
             | Setting Name          | Code | Specification |
             +-----------------------+------+---------------+
             | HEADER_TABLE_SIZE     | 0x1  | Section 4     |
             |                       |      |               |
             | QPACK_BLOCKED_STREAMS | 0x7  | Section 4     |
             +-----------------------+------+---------------+

8.2.  Stream Type Registration

   This document creates two new settings in the "HTTP/QUIC Stream Type"
   registry established in [QUIC-HTTP].

   The entries in the following table are registered by this document.

         +----------------------+------+---------------+--------+
         | Stream Type          | Code | Specification | Sender |
         +----------------------+------+---------------+--------+
         | QPACK Encoder Stream | 0x48 | Section 5     | Both   |
         |                      |      |               |        |
         | QPACK Decoder Stream | 0x68 | Section 5     | Both   |
         +----------------------+------+---------------+--------+

9.  References

7.1.

9.1.  Normative References

   [QUIC-HTTP]
              Bishop, M., Ed., "Hypertext Transfer Protocol (HTTP) over
              QUIC", draft-ietf-quic-http-12 draft-ietf-quic-http-13 (work in progress), April June
              2018.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC7541]  Peon, R. and H. Ruellan, "HPACK: Header Compression for
              HTTP/2", RFC 7541, DOI 10.17487/RFC7541, May 2015,
              <https://www.rfc-editor.org/info/rfc7541>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

7.2.

9.2.  Informative References

   [QUIC-TRANSPORT]
              Iyengar, J. and M. Thomson, "QUIC: A UDP-Based Multiplexed
              and Secure Transport", draft-ietf-quic-transport-11 draft-ietf-quic-transport-12 (work
              in progress), April May 2018.

   [RFC2360]  Scott, G., "Guide for Internet Standards Writers", BCP 22,
              RFC 2360, DOI 10.17487/RFC2360, June 1998,
              <https://www.rfc-editor.org/info/rfc2360>.

   [RFC7540]  Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext
              Transfer Protocol Version 2 (HTTP/2)", RFC 7540,
              DOI 10.17487/RFC7540, May 2015,
              <https://www.rfc-editor.org/info/rfc7540>.

7.3.

9.3.  URIs

   [1] https://mailarchive.ietf.org/arch/search/?email_list=quic

   [2] https://github.com/quicwg

   [3] https://github.com/quicwg/base-drafts/labels/-qpack

Acknowledgments

   This draft draws heavily on the text of [RFC7541].  The indirect
   input of those authors is gratefully acknowledged, as well as ideas
   from:

   o  Ryan Hamilton

   o  Patrick McManus

   o  Kazuho Oku

   o  Biren Roy

   o  Ian Swett

   o  Dmitri Tikhonov

Appendix A.  Change Log

      *RFC Editor's Note:* Please remove this section prior to
      publication of a final version of this document.

B.1.

A.1.  Since draft-ietf-quic-qpack-00

   o  Renumbered instructions for consistency (#1471, #1472)

   o  Decoder is allowed to validate largest reference (#1404, #1469)
   o  Header block acknowledgments also acknowledge the associated
      largest reference (#1370, #1400)

   o  Added an acknowledgment for unread streams (#1371, #1400)

   o  Removed framing from encoder stream (#1361,#1467)

   o  Control streams use typed unidirectional streams rather than fixed
      stream IDs (#910,#1359)

A.2.  Since draft-ietf-quic-qcram-00

   o  Separate instruction sets for table updates and header blocks
      (#1235, #1142, #1141)

   o  Reworked indexing scheme (#1176, #1145, #1136, #1130, #1125,
      #1314)

   o  Added mechanisms that support one-pass encoding (#1138, #1320)

   o  Added a setting to control the number of blocked decoders (#238,
      #1140, #1143)

   o  Moved table updates and acknowledgments to dedicated streams
      (#1121, #1122, #1238)

Acknowledgments

   This draft draws heavily on the text of [RFC7541].  The indirect
   input of those authors is gratefully acknowledged, as well as ideas
   from:

   o  Ryan Hamilton

   o  Patrick McManus

   o  Kazuho Oku

   o  Biren Roy

   o  Ian Swett

   o  Dmitri Tikhonov

   Buck's contribution was supported by Google during his employment
   there.

   A substantial portion of Mike's contribution was supported by
   Microsoft during his employment there.

Authors' Addresses

   Charles 'Buck' Krasic
   Google, Inc
   Netflix

   Email: ckrasic@google.com ckrasic@netflix.com

   Mike Bishop
   Akamai Technologies

   Email: mbishop@evequefou.be

   Alan Frindell (editor)
   Facebook

   Email: afrind@fb.com