lib: add bufq and dynhds

Adding `bufq`:
- at init() time configured to hold up to `n` chunks of `m` bytes each.
- various methods for reading from and writing to it.
- `peek` support to get access to buffered data without copy
- `pass` support to allow buffer flushing on write if it becomes full
- use case: IO buffers for dynamic reads and writes that do not blow up
- distinct from `dynbuf` in that:
  - it maintains a read position
  - writes on a full bufq return CURLE_AGAIN instead of nuking itself
- Init options:
  - SOFT_LIMIT: allow writes into a full bufq
  - NO_SPARES: free empty chunks right away
- a `bufc_pool` that can keep a number of spare chunks to
  be shared between different `bufq` instances

Adding `dynhds`:
- a straightforward list of name+value pairs as used for HTTP headers
- headers can be appended dynamically
- headers can be removed again
- headers can be replaced
- headers can be looked up
- http/1.1 formatting into a `dynbuf`
- configured at init() with limits on header counts and total string
  sizes
- use case: pass a HTTP request or response around without being version
  specific
- express a HTTP request without a curl easy handle (used in h2 proxy
  tunnels)
- future extension possibilities:
  - conversions of `dynhds` to nghttp2/nghttp3 name+value arrays

Closes #10720
This commit is contained in:
Stefan Eissing 2023-03-20 14:23:53 +01:00 committed by Daniel Stenberg
parent 8cabef6fc3
commit 61f52a97e9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
15 changed files with 2070 additions and 3 deletions

View file

@ -250,7 +250,7 @@ test2400 test2401 test2402 test2403 \
\
test2500 test2501 test2502 test2503 \
\
test2600 \
test2600 test2601 test2602 \
\
test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \

22
tests/data/test2601 Normal file
View file

@ -0,0 +1,22 @@
<testcase>
<info>
<keywords>
unittest
bufq
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<features>
unittest
</features>
<name>
bufq unit tests
</name>
</client>
</testcase>

22
tests/data/test2602 Normal file
View file

@ -0,0 +1,22 @@
<testcase>
<info>
<keywords>
unittest
dynhds
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<features>
unittest
</features>
<name>
dynhds unit tests
</name>
</client>
</testcase>