]> git.ipfire.org Git - thirdparty/curl.git/commit
lib: add `bufq` and `dynhds`
authorStefan Eissing <stefan@eissing.org>
Mon, 20 Mar 2023 13:23:53 +0000 (14:23 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 30 Mar 2023 07:08:05 +0000 (09:08 +0200)
commit61f52a97e9fd1bb79f1b312fe031ceb95fd13d27
treea66c5448188d73f07fe4a8f3e9a971208e794fa5
parent8cabef6fc312b7a59e2cbf73fabd9f3cc2b459ba
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
15 files changed:
lib/Makefile.inc
lib/bufq.c [new file with mode: 0644]
lib/bufq.h [new file with mode: 0644]
lib/dynhds.c [new file with mode: 0644]
lib/dynhds.h [new file with mode: 0644]
lib/http.c
lib/http.h
tests/data/Makefile.inc
tests/data/test2601 [new file with mode: 0644]
tests/data/test2602 [new file with mode: 0644]
tests/unit/CMakeLists.txt
tests/unit/Makefile.am
tests/unit/Makefile.inc
tests/unit/unit2601.c [new file with mode: 0644]
tests/unit/unit2602.c [new file with mode: 0644]