Hi,

I have a use-case where I'm trying to delete only specific "Set-Cookie" headers 
from a response. Since the "Set-Cookie" header can be repeated multiple times, 
the response might look like:

Set-Cookie: foo1=value1
Set-Cookie: foo2=value2
Set-Cookie: bar=value3

In my case, I'd only like to delete the "Set-Cookie: foo\d+" lines, but keep 
the "Set-Cookie: bar" line. Is this something that's possible in HAProxy 2?

I think this could previously be accomplished with the old "rspidel" option 
since it operated on matching full header lines. However, I can't figure out 
any way to accomplish this with the newer "http-response del-header" option 
since it deletes all headers matching a name without a way to target specific 
lines based on the value (as far as I can tell).

The "http-response replace-header" option can sort of be used to replace the 
value of these specific header lines based on values, but you can't actually 
delete the lines. For example, this is basically the same issue that's 
described here: 
https://stackoverflow.com/questions/67203673/cant-remove-just-one-set-cookie-header-in-haproxy-2-2
 Where a suggestion is to do something like "http-response replace-header 
Set-Cookie foo\d+ \2" which would result in an empty "Set-Cookie: " header, or 
"http-response replace-header Set-Cookie foo\d+ bogus-cookie=bogus-value". But 
those "Set-Cookie" header lines still remain, instead of being deleted entirely.

So is this deletion of specific header lines with a specific name and value 
(while keeping other header lines of the same name) something that's possible? 
Or is that no longer possible without something like respidel that could match 
both the header name and value? This might be an uncommon use-case, but I was 
just trying to figure out if I was missing some other way to accomplish this.

Thank you!
Nick

Reply via email to