Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: support status code 102 (Processing) in ResponseWriter #36734

Open
majewsky opened this issue Jan 24, 2020 · 6 comments · May be fixed by #42597 or golang/net#96
Open

net/http: support status code 102 (Processing) in ResponseWriter #36734

majewsky opened this issue Jan 24, 2020 · 6 comments · May be fixed by #42597 or golang/net#96

Comments

@majewsky
Copy link

@majewsky majewsky commented Jan 24, 2020

HTTP status code 102 (Processing) is defined by RFC 2518, section 10.1:

This status code SHOULD only be sent when the server has a reasonable expectation that the request will take significant time to complete. [...] The server MUST send a final response after the request has been completed.

As of now (Go 1.13.6), there is no way to actually send a 102 response because ResponseWriter.WriteHeader() can only be called once. Any successive calls are rejected (here).

Since the ResponseWriter interface cannot be extended without breaking backwards compatibility, a new interface should be added (and implemented by the existing ResponseWriter implementations) that exposes a function for sending an interim response with status 102.

@toothrot toothrot added this to the Backlog milestone Jan 24, 2020
@toothrot
Copy link
Contributor

@toothrot toothrot commented Jan 24, 2020

WebDAV specific features might be better suited for x/net/webdav. I'm not positive we could make this change in net/http while maintaining API compatibility.

/cc @bradfitz @nigeltao

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jan 24, 2020

I don't think we'd need API changes. We could just permit WriteHeader(102) followed by a non-1xx status later

@Artheriom
Copy link

@Artheriom Artheriom commented Sep 1, 2020

Hey,

Any update about this ? It would be a nice feature.

For my use case, it doesn't have any link with WebDAV. I have some very long requests, who can make hundreds of other requests to various requests, and adding this kind of functionality would enable my users to stay listening at the server. Currently, they are in timeout...

Also, for the net/http and not a WebDav-specific protocol, this improvement would permit developers to use HTTP 103 - Early Hints (https://tools.ietf.org/html/rfc8297, still experimental, but exists).

The change is pretty simple : if status is 1xx, we allow update, if not we reject as it is currently done. (show concerned line)

dunglas added a commit to dunglas/go that referenced this issue Nov 13, 2020
Currently, it's not possible to send informational responses
such as 103 Early Hints or 102 Processing.

This patch allows calling 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 is also sent. Its content is not removed
after the call to WriteHeader() because the headers must also be
included in the final response.

The Chrome and Fastly teams are starting a large-scale experiment to measure
the real-life impact of the 103 status code.
Using Early Hints is proposed as a (partial) alternative to Server Push,
which are going to be removed from Chrome: https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/21anpFhxAQAJ

Being able to send this status code from servers implemented using Go would help
to see if implementing it in browsers is worth it.

Fixes golang#26089.
Fixes golang#36734.
Updates golang#26088.
@dunglas dunglas linked a pull request that will close this issue Nov 13, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Nov 13, 2020

Change https://golang.org/cl/269997 mentions this issue: net/http: allow sending 1xx responses

@gopherbot
Copy link

@gopherbot gopherbot commented Nov 14, 2020

Change https://golang.org/cl/270157 mentions this issue: http2: allow sending 1xx responses

dunglas added a commit to dunglas/go that referenced this issue Feb 10, 2021
Currently, it's not possible to send informational responses
such as 103 Early Hints or 102 Processing.

This patch allows calling 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 is also sent. Its content is not removed
after the call to WriteHeader() because the headers must also be
included in the final response.

The Chrome and Fastly teams are starting a large-scale experiment to measure
the real-life impact of the 103 status code.
Using Early Hints is proposed as a (partial) alternative to Server Push,
which are going to be removed from Chrome: https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/21anpFhxAQAJ

Being able to send this status code from servers implemented using Go would help
to see if implementing it in browsers is worth it.

Fixes golang#26089.
Fixes golang#36734.
Updates golang#26088.
@dunglas dunglas linked a pull request that will close this issue Feb 10, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Feb 10, 2021

Change https://golang.org/cl/291029 mentions this issue: http2: allow sending 1xx responses

dunglas added a commit to dunglas/go that referenced this issue Mar 5, 2021
Currently, it's not possible to send informational responses
such as 103 Early Hints or 102 Processing.

This patch allows calling 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 is also sent. Its content is not removed
after the call to WriteHeader() because the headers must also be
included in the final response.

The Chrome and Fastly teams are starting a large-scale experiment to measure
the real-life impact of the 103 status code.
Using Early Hints is proposed as a (partial) alternative to Server Push,
which are going to be removed from Chrome: https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/21anpFhxAQAJ

Being able to send this status code from servers implemented using Go would help
to see if implementing it in browsers is worth it.

Fixes golang#26089.
Fixes golang#36734.
Updates golang#26088.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants