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)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Nov 2021 15:34:06 +0000 (16:34 +0100)
commitf776dc2831f21dd81c67c4765f977bb748bf42d2
tree159891e7d93bcfc79ce03a7e71b20bdd520a18ca
parent105d510ad2cd79905f6fb58e65e8a8c694f578f7
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.

(cherry picked from commit 66255f7bbf9dfa18545d96f87d7a0f6fb8684d1c)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit a7e8485838e30f921b9d34045f0ebf8672bb0259)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
contrib/halog/halog.c