-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: add ResponseController.EnableFullDuplex #57786
Comments
"bidi" often means bidirectional text like Unicode LTR/RTL. |
This proposal has been added to the active column of the proposals project |
I don't believe there is a standard name for this behavior. I'm not committed to the name here;
Ideally we wouldn't have a knob here, but I don't see how to avoid it; there are valid reasons to want both possible behaviors here, and changing our current default will break some users. |
informational rfc: bidirectional http |
I like And perhaps only permit enabling full duplex, to avoid any questions about what it means to disable it with HTTP/2 or HTTP/3.
|
With the renaming to EnableFullDuplex, have all the concerns about this proposal been addressed? |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/472636 mentions this issue: |
Change https://go.dev/cl/472717 mentions this issue: |
Add support for concurrently reading from an HTTP/1 request body while writing the response. Normally, the HTTP/1 server automatically consumes any remaining request body before starting to write a response, to avoid deadlocking clients which attempt to write a complete request before reading the response. Add a ResponseController.EnableFullDuplex method which disables this behavior. For #15527 For #57786 Change-Id: Ie7ee8267d8333e9b32b82b9b84d4ad28ab8edf01 Reviewed-on: https://go-review.googlesource.com/c/go/+/472636 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Damien Neil <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]>
Change https://go.dev/cl/501300 mentions this issue: |
For #15527 For #57786 Change-Id: I75ed0b4bac8e31fac2afef17dad708dc9a3d74e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/501300 Run-TryBot: Damien Neil <[email protected]> Auto-Submit: Damien Neil <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
Do we have a rough idea of which clients don't support full-duplex? Is there a list of clients known to produce deadlocks? I'm asking because we're adding this as an opt-in config option in Caddy (for ref: caddyserver/caddy#5654), and I'd like it if I could document something like "don't enable this if you know you have such and such clients connecting to your server". I'd also consider enabling this by default if it's really only super-old clients that don't handle this properly (e.g. only old browsers that nobody should be using anymore anyway, or old versions of curl, etc). |
Sorry, I've got no idea how common this client behavior is. I wouldn't expect this to be an issue for browsers (although I haven't checked any), but browsers are also unlikely to be sending requests that need full duplex handling. The simplest implementation of an HTTP client is to open a connection, write a request, and read a response. I suspect there are a fair number of versions of that out in the wild. |
This has been implemented, documented and released in go1.21, so I guess this issue can be closed. |
This proposal aims to address #15527.
The
net/http
HTTP/1 server does not permit reading from an inbound request body after starting to write the response. (See theResponseWriter.Write
documentation).This limitation is because the server drains any unread portion of the request body before writing the response headers, to avoid deadlocking clients that attempt to write a complete request before reading the response. (See #15527 (comment) for more context.)
I propose that we offer an opt-in mechanism to disable this behavior, permitting a server handler to write some or all of the response interleaved with reads from the request.
The text was updated successfully, but these errors were encountered: