]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: http_ext: implement rfc7239_{nn,np} converters
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 14 Oct 2024 17:49:32 +0000 (19:49 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Thu, 17 Oct 2024 15:24:58 +0000 (17:24 +0200)
commitd28d016f4304c18d31f3c6505e1e97c3e5e7f52c
treee91e7c47dcfe3c305304c776148adb5277c5e6b0
parent45cbbdc84551e51cdaf0046e1371e8495d053fb5
MINOR: http_ext: implement rfc7239_{nn,np} converters

"option forwarded" provides a convenient way to automatically insert
rfc7239 forwarded header to requests sent to servers.

On the other hand, manually crafting the header is quite complicated due
to specific formatting rules that must be followed as per rfc7239.
However, sometimes it may be necessary to craft the header manually, for
instance if it has to be conditional or based on parameters that "option
forwarded" doesn't provide. To ease this task, in this patch we implement
rfc7239_nn and rfc7239_np which are respectively meant to craft nodename:
nodeport values, specifically intended to manually build rfc7239 'for'
and 'by' header fields while ensuring rfc7239 compliancy.

Example:
  # build RFC-compliant 7239 header:
  http-request set-var-fmt(txn.forwarded) "for=\"%[ipv6(::1),rfc7239_nn]:%[str(8888),rfc7239_np]\";host=\"haproxy.org\";proto=http"
  # check RFC-compliancy:
  http-request set-var(txn.test) "var(txn.forwarded),debug(ok,stderr),rfc7239_is_valid,debug(ok,stderr)"
  #  stderr output:
  #    [debug] ok: type=str <for="[::1]:_8888";host="haproxy.org";proto=http>
  #    [debug] ok: type=bool <1>

See documentation for more info and examples.
doc/configuration.txt
src/http_ext.c