Skip to content

Both 'Content-Length: 0' and 'Transfer-Encoding: chunked' found when 'Accept-encoding: gzip' header not sent #732

@ShaharTrasmitSecurity

Description

@ShaharTrasmitSecurity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions