Add reason phrase to response

Can I somehow add the HTTP reason phrase e.g. “OK” (RFC 2616 - Hypertext Transfer Protocol -- HTTP/1.1) to the HTTP response in HAProxy?

My webserver doesn’t support reason phrases, but a client software requires it.

Based on:

https://cbonte.github.io/haproxy-dconv/2.4/configuration.html#4.2-http-response%20set-status

https://cbonte.github.io/haproxy-dconv/2.4/configuration.html#7.3.6-status

I’d guess something like:

http-response set-status 200 reason "OK" if { status 200 }

It works, thank you!

I ended up adding all possible return codes:

    http-response set-status 100 reason "Continue" if { status 100 }
    http-response set-status 101 reason "Switching Protocols" if { status 101 }
    http-response set-status 200 reason "OK" if { status 200 }
    http-response set-status 201 reason "Created" if { status 201 }
    http-response set-status 202 reason "Accepted" if { status 202 }
    http-response set-status 203 reason "Non-Authoritative Information" if { status 203 }
    http-response set-status 204 reason "No Content" if { status 204 }
    http-response set-status 205 reason "Reset Content" if { status 205 }
    http-response set-status 206 reason "Partial Content" if { status 206 }
    http-response set-status 300 reason "Multiple Choices" if { status 300 }
    http-response set-status 301 reason "Moved Permanently" if { status 301 }
    http-response set-status 302 reason "Found" if { status 302 }
    http-response set-status 303 reason "See Other" if { status 303 }
    http-response set-status 304 reason "Not Modified" if { status 304 }
    http-response set-status 305 reason "Use Proxy" if { status 305 }
    http-response set-status 307 reason "Temporary Redirect" if { status 307 }
    http-response set-status 400 reason "Bad Request" if { status 400 }
    http-response set-status 401 reason "Unauthorized" if { status 401 }
    http-response set-status 402 reason "Payment Required" if { status 402 }
    http-response set-status 403 reason "Forbidden" if { status 403 }
    http-response set-status 404 reason "Not Found" if { status 404 }
    http-response set-status 405 reason "Method Not Allowed" if { status 405 }
    http-response set-status 406 reason "Not Acceptable" if { status 406 }
    http-response set-status 407 reason "Proxy Authentication Required" if { status 407 }
    http-response set-status 408 reason "Request Time-out" if { status 408 }
    http-response set-status 409 reason "Conflict" if { status 409 }
    http-response set-status 410 reason "Gone" if { status 410 }
    http-response set-status 411 reason "Length Required" if { status 411 }
    http-response set-status 412 reason "Precondition Failed" if { status 412 }
    http-response set-status 413 reason "Request Entity Too Large" if { status 413 }
    http-response set-status 414 reason "Request-URI Too Large" if { status 414 }
    http-response set-status 415 reason "Unsupported Media Type" if { status 415 }
    http-response set-status 416 reason "Requested range not satisfiable" if { status 416 }
    http-response set-status 417 reason "Expectation Failed" if { status 417 }
    http-response set-status 500 reason "Internal Server Error" if { status 500 }
    http-response set-status 501 reason "Not Implemented" if { status 501 }
    http-response set-status 502 reason "Bad Gateway" if { status 502 }
    http-response set-status 503 reason "Service Unavailable" if { status 503 }
    http-response set-status 504 reason "Gateway Time-out" if { status 504 }
    http-response set-status 505 reason "HTTP Version not supported" if { status 505 }