Re: Always add "reason"
Il 2022-03-11 18:00 Willy Tarreau ha scritto: Hi Marco, On Thu, Mar 03, 2022 at 12:26:09PM +0100, Marco Corte wrote: Hi! I can add a "reason phrase" to a response based on the HTTP status like this: http-response set-status 200 reason OK if { status eq 200 } Is there any way to add the reason phrase for a set of codes without an explicit rule for each code? I would like to write a set of rules like this http-response set-status 200 reason OK if { status eq 200 } http-response set-status %[status] reason NotOK unless { status eq 200 } Unfortunately I don't see a way to easily do this. I didn't even remembered that the internal representation for the reason was conveyed, I thought it was built when serializing the status on the wire. In fact, since the advent of HTTP/2 which completely dropped the reason phrase, you really cannot trust that element anymore at all. It used to be very unreliable even before HTTP/2 since plenty of proxies were placing their own reason for a given code, but nowadays it's really impossible to trust it anymore. Out of curiosity, what would be your use case ? Hi, Willy In this case haproxy is used to wrap a service for a legacy(*) client, that uses "reason" to process the response. Thank you for your answer! .marcoc (*) the correct spelling whould be: fu%#!#@-old-out-of-standard client.
Re: Always add "reason"
Hi Marco, On Thu, Mar 03, 2022 at 12:26:09PM +0100, Marco Corte wrote: > Hi! > > I can add a "reason phrase" to a response based on the HTTP status like > this: > > http-response set-status 200 reason OK if { status eq 200 } > > Is there any way to add the reason phrase for a set of codes without an > explicit rule for each code? > I would like to write a set of rules like this > > http-response set-status 200 reason OK if { status eq 200 } > http-response set-status %[status] reason NotOK unless { status eq 200 } Unfortunately I don't see a way to easily do this. I didn't even remembered that the internal representation for the reason was conveyed, I thought it was built when serializing the status on the wire. In fact, since the advent of HTTP/2 which completely dropped the reason phrase, you really cannot trust that element anymore at all. It used to be very unreliable even before HTTP/2 since plenty of proxies were placing their own reason for a given code, but nowadays it's really impossible to trust it anymore. Out of curiosity, what would be your use case ? Thanks, Willy
Always add "reason"
Hi! I can add a "reason phrase" to a response based on the HTTP status like this: http-response set-status 200 reason OK if { status eq 200 } Is there any way to add the reason phrase for a set of codes without an explicit rule for each code? I would like to write a set of rules like this http-response set-status 200 reason OK if { status eq 200 } http-response set-status %[status] reason NotOK unless { status eq 200 } Thank you .marcoc