MEDIUM: h1-htx: Add a function to parse contiguous small chunks
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 21 May 2021 09:05:12 +0000 (11:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 25 May 2021 08:41:50 +0000 (10:41 +0200)
commitbdcefe58b7190d919d2728f8a412bc4f58908c76
treecc45124680e36ff52d01e79e4d631eed1b8dd8e7
parent0d4c924c34c3f6affed4538c489657eec32decb7
MEDIUM: h1-htx: Add a function to parse contiguous small chunks

Add h1_parse_full_contig_chunks() function to parse full contiguous chunks.
This function neither handles incomplete chunks nor wrapping buffers. It is
designed to efficiently parse a buffer with several small chunks. Of course,
there is no zero copy here because it is not possible. This function is a
bit tricky and all changes may a have a impact. This one may probably be
optimized, but it is good enough for now and not too complex.

The main function (h1_parse_msg_chunks) always tries to use this function
when the HTTP parser is waiting for a chunk size. In this case, there is no
zero-copy, so there is no reason to call the generic version to parse the
chunk. However, if some unparsed data remain after this step, the generic
function is called. This way, wrapping data and incomplete chunks may be
parsed.

Quick tests show it is now slightly faster in all cases than the legacy
mode.
src/h1_htx.c