Skip to content

Misleading early response warning on HTTP/1.1 HEAD/OPTIONS requests with Transfer-Encoding: chunked #4462

@samerdokas

Description

@samerdokas

Consider a no-body OPTIONS request, as could be sent via curl:

curl -v -i -X OPTIONS -H 'Host: example.com' -H 'Access-Control-Request-Method: POST' -H 'Access-Control-Request-Headers: content-type' -H 'sec-fetch-mode: cors' -H 'sec-fetch-site: cross-site' -H 'sec-fetch-dest: empty' -H 'transfer-encoding: chunked' --http1.1 https://example.com/example

This request does satisfy the OPTIONS requirement of not having a body:

  • no body (--data or similar) is specified in the curl invocation
  • the client, be it curl (in this simple example), Safari or whatever else, will immediately send a chunk data size of 0.

As described in RFC9112

The chunked transfer coding is complete when a chunk with a chunk-size of zero is received, possibly followed by a trailer section, and finally terminated by an empty line.

or MDN HTTP Reference:

The terminating chunk is a zero-length chunk.

As such, any application that does HEAD/OPTIONS handling will typically not attempt to read the request body when handling these methods. Unfortunately, doing complete() on this kind of a request will generate the

Sending an 2xx 'early' response before end of request for https://example.com/example received... Note that the connection will be closed after this response. Also, many clients will not read early responses! Consider only issuing this response after the request data has been completely read!

every time, essentially generating worthless warnings. Note that there is no method logged, so there is no way to workaround this by filtering away only the warnings related to HEAD/OPTIONS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1 - triagedTickets that are safe to pick up for contributing in terms of likeliness of being acceptedt:serverIssues related to the HTTP server

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions