Curl not closed when 204 No-Content and Transfer-Encoding: chunked through haproxy

Haproxy is terminating https connections and forwards requests to backend. When resource returns 204 No-Content and Transfer-Encoding: chunked the curl connection is not closed. When I call resource directly on backend, the connection is closed properly. Can anybody explain this behaviour?

Through haproxy:
curl -X GET https://localhost/example -v
* About to connect() to localhost port 443 (#0)
* Trying 127.0.0.1…
* Connected to localhost (127.0.0.1) port 443 (#0)
> GET /example HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost
> Accept: /
>
< HTTP/1.1 204 No Content
< Cache-Control: no-cache, no-store, must-revalidate
< Date: Wed, 23 Aug 2017 13:15:16 GMT
< transfer-encoding: chunked
<
^C

Directly backend:

curl -X GET http://localhost:6083/example -v
* About to connect() to localhost port 6083 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 6083 (#0)
> GET /example HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:6083
> Accept: */*
>
< HTTP/1.1 204 No Content
< Cache-Control: no-cache, no-store, must-revalidate
< Date: Wed, 23 Aug 2017 14:19:03 GMT
< transfer-encoding: chunked
<
* Connection #0 to host localhost left intact

This is an invalid response and an RFC violation:

A server MUST NOT send a Transfer-Encoding header field in any
response with a status code of 1xx (Informational) or 204 (No
Content).