MINOR: halog: Add support for extracting captures using -hdr
authorTim Duesterhus <duesterhus@woltlab.com>
Thu, 28 Oct 2021 15:24:02 +0000 (17:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Oct 2021 17:44:18 +0000 (19:44 +0200)
commit66255f7bbf9dfa18545d96f87d7a0f6fb8684d1c
treec89af4bacf2793298282776fac77497c79b5fe1b
parenta02c7b882f34fbb29cc71bf5ce744b0f42bacbe3
MINOR: halog: Add support for extracting captures using -hdr

This patch adds support for extracting captured header fields to halog. A field
can be extracted by passing the `-hdr <block>:<field>` output filter.

Both `<block>` and `<field>` are 1-indexed.

`<block>` refers to the index of the brace-delimited list of headers. If both
request and response headers are captured, then request headers are referenced
by `<block> = 1`, response headers are `2`. If only one direction is captured,
there will only be a single block `1`.

`<field>` refers to a single field within the selected block.

The output will contain one line, possibly empty, per log line processed.
Passing a non-existent `<block>` or `<field>` will result in an empty line.

Example:

    capture request  header a len 50
    capture request  header b len 50
    capture request  header c len 50
    capture response header d len 50
    capture response header e len 50
    capture response header f len 50

`-srv 1:1` will extract request  header `a`
`-srv 1:2` will extract request  header `b`
`-srv 1:3` will extract request  header `c`
`-srv 2:3` will extract response header `f`

This resolves GitHub issue #1146.
admin/halog/halog.c