According to the http 1.1 spec:
A sender MUST NOT send a Content-Length header field in any message
that contains a Transfer-Encoding header field. (https://tools.ietf.org/html/rfc7230#section-3.3.2).
When testing prometheus metrics exposition, we are creating HTTPServer (in io.prometheus.client.exporter.HTTPServer) to expose metrics to, and sending HTTP requests to query the exposed metrics
When no metrics matches the query and an empty response should return, the following exception occur:
java.lang.IllegalArgumentException: Both 'Content-Length: 0' and 'Transfer-Encoding: chunked' found
After debugging, i found that when gzip encoding is not allowed (through Accept-encoding header), the response will always be encoded as chunked, and will contain the Content-Length: 0 header which conflicts with the HTTP 1.1 spec
** The issue occur only when the content length is 0