I have setup haproxy 1.7.8 with option httpchk for my backend servers and have working GET requests.
But while configuring the POST request with json data, I am getting error code 400.
Here is my check added in backend block,
option httpchk POST /myService/endpt HTTP/1.1\r\nContent-Type:\ application/json;charset=UTF-8\r\nContent-Length:\ 169\r\n\r\n{\"inputs\":[{\"id\":1,\"productType\":\"productType\",\"productDescription\":\"productDescription\",\"metaDescription\":\"metaDescription\",\"metaTitle\":\"metaTitle\",\"rawxyz\":\"rawxyz\"}]} http-check expect rstatus (2|3)[0-9][0-9]
After debugging with wireshark capture I came to know that, haproxy is adding \r\f"Connection: close"\r\f\r\f at the end of the post json data.
From this manual, https://www.haproxy.org/download/1.7/doc/configuration.txt, I found that haproxy appends it if httpchk is combined with http-check expect.
But it should be added to header fields and not after data.
This is causing packet parse failure, as it considering POST data as a part of header and reporting extra CRLF in headers.
I would need the http-check expect block to verify error code, but then how would I avoid adding Connection: close at the end.
I tried adding it as part of header itself, but it still appends one of its own.
Is it a bug? I can’t find it in known bugs list.