Skip to content

Commit bfa7675

Browse files
odoucethdurand0710
authored andcommitted
DOC/MINOR: update request-capture documentation to clarify header handling
1 parent a239db2 commit bfa7675

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

documentation/annotations.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,9 +1316,11 @@ rate-limit-whitelist: "10.0.0.0/8, 192.168.1.100"
13161316

13171317
:information_source: Captures samples of the request using [sample expression](#sample-expression) and log them in HAProxy traffic logs.
13181318

1319+
:information_source: **Important**: When capturing headers that may contain commas (like `User-Agent`), use `req.fhdr(header-name)` instead of `hdr(header-name)`. The `hdr()` function splits values on commas, which can result in truncated or malformed log entries. The `req.fhdr()` function returns the full header value without splitting on commas.
1320+
13191321
Possible values:
13201322

1321-
- A header value, e.g. `hdr(header-name)`
1323+
- A header value, e.g. `hdr(header-name)` or `req.fhdr(header-name)` for headers with commas
13221324
- A cookie value, e.g. `cookie(cookie-name)`
13231325
- Multiple expressions by using a multiline YAML string
13241326

@@ -1332,7 +1334,7 @@ request-capture: cookie(my-cookie)
13321334
request-capture: |
13331335
cookie(my-cookie)
13341336
hdr(Host)
1335-
hdr(User-Agent)
1337+
req.fhdr(user-agent)
13361338
```
13371339

13381340
Example (ingress):
@@ -1345,7 +1347,7 @@ haproxy.org/request-capture: cookie(my-cookie)
13451347
haproxy.org/request-capture: |
13461348
cookie(my-cookie)
13471349
hdr(Host)
1348-
hdr(User-Agent)
1350+
req.fhdr(user-agent)
13491351
```
13501352

13511353
##### `request-capture-len`

documentation/doc.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,8 +1383,12 @@ annotations:
13831383
tip:
13841384
- Captures samples of the request using [sample expression](#sample-expression)
13851385
and log them in HAProxy traffic logs.
1386+
- '**Important**: When capturing headers that may contain commas (like `User-Agent`),
1387+
use `req.fhdr(header-name)` instead of `hdr(header-name)`. The `hdr()` function
1388+
splits values on commas, which can result in truncated or malformed log entries.
1389+
The `req.fhdr()` function returns the full header value without splitting on commas.'
13861390
values:
1387-
- A header value, e.g. `hdr(header-name)`
1391+
- A header value, e.g. `hdr(header-name)` or `req.fhdr(header-name)` for headers with commas
13881392
- A cookie value, e.g. `cookie(cookie-name)`
13891393
- Multiple expressions by using a multiline YAML string
13901394
applies_to:
@@ -1399,7 +1403,7 @@ annotations:
13991403
request-capture: |
14001404
cookie(my-cookie)
14011405
hdr(Host)
1402-
hdr(User-Agent)
1406+
req.fhdr(user-agent)
14031407
example_ingress: |-
14041408
# capture a single value
14051409
haproxy.org/request-capture: cookie(my-cookie)
@@ -1408,7 +1412,7 @@ annotations:
14081412
haproxy.org/request-capture: |
14091413
cookie(my-cookie)
14101414
hdr(Host)
1411-
hdr(User-Agent)
1415+
req.fhdr(user-agent)
14121416
- title: request-capture-len
14131417
type: number
14141418
group: request-capture

0 commit comments

Comments
 (0)