Skip to content

net/http: support for the 103 status code #51914

Closed
@dunglas

Description

@dunglas

Currently, it's not possible to send informational HTTP responses with, for example, the 103 Early Hints or 102 Processing status codes.

Using Early Hints is proposed as a (partial) alternative to Server Push, which is going to be removed from Chrome.

Chrome 95 added experimental support for the 103 status code (currently behind a flag). Support is being implemented in Firefox. Fastly and Google are also running a joint experiment to measure real-life benefits of this new status code.

I propose to change the API of net/http to allow calling ResponseWriter.WriteHeader() multiple times in order to send informational responses before the final one. In conformance with RFC 8297, if the status code is 103 the current content of the header map will also be sent. Its content will not be removed after the call to WriteHeader() because the headers must also be included in the final response.

I also propose adding support for 103 responses to net/http/httputil. I suggest introducing a new exported field, ReverseProxy.Forward103Responses, to enable this feature (I think that forwarding 103 responses should be opt-in, as it may cause compatibility issues with some legacy software).

I already crafted the patch implementing this proposal for HTTP/1, HTTP/2, and HTTP/3. Patches for HTTP/1 and 2 have been reviewed by @bradfitz. The one for HTTP/3 is already merged in lucas-clemente/quic-go.

Related patches:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions