This one might be better for review as it's more complete, also
implements del-headers-bin, has a filter for headers that shouldn't be
touched, has documentation and fixes some bugs in the first one.

Regards,
Nenad


On Tue, Feb 3, 2026 at 1:47 AM Nenad Merdanovic
<[email protected]> wrote:
>
> Hello,
>
> I would like to discuss the possibility of adding a feature to set/add
> multiple headers in the same http-request/response command and the
> best way to implement that.
>
> The main driver behind this is being able to return any number of
> headers with names unknown in advance from SPOA that would then be set
> by HAProxy, both upstream and downstream.
>
> A consideration has to be made that some headers must not be reset.
> The list I came up with is: connection, content-length, expect,
> keep-alive, proxy-authenticate, proxy-authorization, proxy-connection,
> trailer, transfer-encoding, upgrade. If anyone has any additions,
> please let me know.
>
> I made a very rough patch that seems to do what I want it to do, but
> lacks boundary checking and header name filtering, etc. Figured I'd
> get some comments before spending too much time on this. The patch
> adds two new keywords to the HTTP actions, set-headers-bin and
> add-headers-bin. The input is a base64 encoded string created by
> varint encoding the headers, ie. the same encoding used by
> req.hdrs_bin. Also now I noticed the patch doesn't properly free
> "decoded" trash chunk, but that will be fixed before I send a final
> patch, so it can be ignored.
>
> Quick test I made with this config:
>     http-request set-var(txn.oldheaders) req.hdrs_bin,base64
>     http-request del-header Accept
>     http-request del-header User-Agent
>     http-request del-header Host
>     http-request set-headers-bin %[var(txn.oldheaders)]
>     http-request set-var(txn.endheaders) req.hdrs_bin
>     http-after-response set-header Old %[var(txn.oldheaders)]
>     http-after-response set-header End %[var(txn.endheaders)]
>
> Seems to show expected results, as the deleted headers are correctly restored:
>
> HTTP/1.1 200 OK
> content-length: 0
> old: 
> BGhvc3QPbG9jYWxob3N0OjEwMDAwCnVzZXItYWdlbnQLY3VybC84LjExLjEGYWNjZXB0AyovKgAA
> end: %04host%0Flocalhost:10000%0Auser-agent%0Bcurl/8.11.1%06accept%03*/*
>
> Regards,
> Nenad

Attachment: 0001-MEDIUM-Add-set-headers-bin-add-headers-bin-and-del-h.patch
Description: Binary data

Reply via email to