Subject: Questions about QPACK

From: Jiuhai Zhang <[email-masked]>
Date: Thu, 21 Nov 2019 22:06:04 +0800

https://tools.ietf.org/html/draft-ietf-quic-qpack-11#section-4.4.3

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

Q1:why we send N bit to peer? it seems we don't need to send the bit,
if sender don't want to put in dynamic table.

https://tools.ietf.org/html/draft-ietf-quic-qpack-11#section-4.5.4

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

Q2:when we encode new name, new value, we should insert name,value
pair into dynamic table, should we insert name only into dynamic
table?

---

From: Bence Béky <[email-masked]>
Date: Thu, 21 Nov 2019 09:57:24 -0500

Hi,

Great questions.

>
> Q1:why we send N bit to peer? it seems we don't need to send the bit, if sender don't want to put in dynamic table.
>

QPACK is hop-to-hop, that is, client to intermediary, intermediary to
intermediary, intermediary to server, all separately (and the other
way around).  Intermediary can be locally installed
firewall/antivirus, proxy, reverse proxy, load balancer etc.
Intermediaries are allowed to recompress headers using different
algorithms using QPACK, or they might relay to an HTTP/2 connection
using HPACK, etc.  The N bit is to inform intermediaries whether the
original sender of the headers deems that the header MUST always be
encoded using literals.

>
> Q2:when we encode new name, new value, we should insert name,value pair into dynamic table, should we insert name only into dynamic table?
>

Header block representations do not mutate the dynamic table: they do
not insert or duplicate or evict entries or change dynamic table
capacity.  Mutating of the dynamic table only happens on the dedicated
encoder stream.  This is because the order of delivery between header
blocks on different requests streams is not guaranteed, so if
insertions were allowed in header blocks, the order in which these
insertions could arrive would be undefined.

Bence

---

From: Dmitri Tikhonov <[email-masked]>
Date: Thu, 21 Nov 2019 11:25:47 -0500

On Thu, Nov 21, 2019 at 09:57:24AM -0500, Bence Béky wrote:
> > Q1:why we send N bit to peer? it seems we don't need to send the
> > bit, if sender don't want to put in dynamic table.
> 

The HPACK RFC has a whole subsection [1] dedicated to the never-indexed
literals.  The QPACK draft refers to (and subsumes?) [2] the HPACK's
security considerations.

  - Dmitri.

1. https://tools.ietf.org/html/rfc7541#section-7.1.3
2. https://tools.ietf.org/html/draft-ietf-quic-qpack-11#section-7

---

From: Dmitri Tikhonov <[email-masked]>
Date: Fri, 22 Nov 2019 13:51:19 -0500

On Sat, Nov 23, 2019 at 01:23:41AM +0800, 漂泊的梦 wrote:
> Thanks for your reply. There is some misunderstanding about Q2.

>> https://tools.ietf.org/html/draft-ietf-quic-qpack-11#section-4.5.4

The answer to "should" is "depends on what you want to do."  (See below).

> The background is that when the sender inserts the pair of name &amp;
> value into dynamic table, it should also send the pair of name &amp;
> value and index to recipient through encoder stream.&nbsp; In case
> that the pair of name &amp; value cannot be found, we can search by
> name only.&nbsp; The question is that in order to search by name only,
> can we&nbsp;insert name only (without value or with 0-length value)
> and index into the dynamic table, and then send the name and index to
> recipient through encoder stream?  If we don't insert name only and
> index into the dynamic table, how can we search by name only?

Yes, it is valid to insert into the dynamic table an entry with 0-length.
This is useful when the header name repeats, but the value does not.  In
that case, you can reference the dynamic table from the header block via
the Literal Header Field With Name Reference instruction (listed in the
original Q2 above).

  - Dmitri.

---

From: Dmitri Tikhonov <[email-masked]>
Date: Fri, 22 Nov 2019 13:52:10 -0500

> Yes, it is valid to insert into the dynamic table an entry with 0-length.

It should read "with 0-length value."

  - Dmitri.