max-request-headers
Caps the header block, for a caller sending hundreds of cookies or roles. Like max-request-body it is a gate: it decides before anything is transformed and answers the caller itself.
Parameters
| Name | Type | Required | What it does |
|---|---|---|---|
size |
string | yes | The cap, e.g. 16KB, or a number of bytes. |
Units are KB, MB, GB (or K, M, G, B); no unit means bytes. The size must be greater than zero.
Example
filters:
- type: max-request-headers
args:
size: 16KB
Notes
The refusal is a 431, which tells the caller which half to shrink, and it carries the arithmetic: what arrived and what this route accepts. With the 16 KB cap above, a request carrying a 20 KB cookie:
curl -i -b "big=$(head -c 20480 /dev/zero | tr '\0' a)" http://localhost:8080/api/
HTTP/1.1 431 Request Header Fields Too Large
Content-Type: text/plain; charset=utf-8
Cache-Control: no-store
request headers too large: 20.1 KB received, this route accepts 16 KB
The figure received counts the whole header block, so it varies a little with the client's own headers.
What is weighed is the request line plus each header as it would be written on the wire, Host included - the same way Go's own server weighs it. What the gateway adds afterwards, such as the forwarding or identity headers, is not counted.