]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: hpack: make it possible to encode any static header name
authorWilly Tarreau <w@1wt.eu>
Mon, 10 Dec 2018 14:19:14 +0000 (15:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Dec 2018 08:06:46 +0000 (09:06 +0100)
commit2c3139489cdb7ee6ff2f03f5e30db212a7d27b63
treeab37536acf020b0c350df06732dc8e9a9f107d0e
parent841bc7d4719f963d564174141ee01e568f57e920
MEDIUM: hpack: make it possible to encode any static header name

We used to have a series of well-known header fields that were looked
up, but most of them were not. The current model couldn't scale with
the addition of the new headers or pseudo-headers required to process
requests, resulting in their encoding being hard-coded in the caller.

This patch implements a quick lookup which retrieves any header from
the static table. A binary stream is made of header names prefixed by
lengths and indexes. These header names are sorted by length, then by
frequency, then by direction (preference for response), then by name,
the the lowest index of each is stored only in case of multiple
entries. A parallel length index table provides the index of the first
header for a given string. This allows to focus on the first few values
matching the same length.

Everything was made to limit the cache footprint. Interestingly, the
lookup ends up being slightly faster than the previous one, while
covering the 54 distinct headers instead of only 10.

A test with a curl request and a basic response showed that the request
size has dropped from 85 to 56 bytes and that the response size has
dropped from 197 to 170 bytes, thus we can now shave roughly 25-30 bytes
per message.
src/hpack-enc.c