Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net/http: add http1 and http2 Server IdleTimeout #14204
If I may ask, this is going to entail us adding
@odeke-em, the naming here is much easier if we don't consider HTTP/2 and PING frames as activity. Then we'd just call it
But with HTTP/2, do we care about clients sending a
Opinions welcome. Ideally with sample documentation you'd tell users.
I got as far as:
So PING frames don't count, then? That's a valid answer.
Now that I think about, we should disable the Transport's TCP keep-alive when HTTP/2 is negotiated, since PING frames and TCP keep-alive packets serve the same purpose of keeping the connection alive from NAT timeouts and whatnot.
Yes, that's the job of the handler or caller of http.Transport.RoundTrip to guard against. We only give a timeout for headers, since the user isn't in control there.
SetReadDeadline is currently only called before a TLS handshake, and before reading request headers, and is never disabled.
So yes, to work similarly to Go 1.0-1.7, we should probably not reset it after the headers and have it apply to the whole request, even if that's slightly odd.
Fix a regression from Go 1.5 to Go 1.6: when we introduced automatic HTTP/2 support in Go 1.6, we never handled Server.ReadTimeout. If a user set ReadTimeout, the net/http package would set the read deadline on the connection during the TLS handshake, but then the http2 package would never disarm it, killing the likely-still-in-use connection after the timeout period. This CL changes it to disarm the timeout after the first request headers, similar to net/http.Server. Unlike net/http.Server, we don't re-arm it on each idle period, because the definition of idle is more complicated with HTTP/2. No tests here for now. Tests will be in the go repo once all the knobs are in place and this is re-bundled into std, testing both http1 and http2. Updates golang/go#16450 (minimal fix for now) Updates golang/go#14204 (considering a new http1+http2 IdleTimeout knob) Change-Id: Iaa1570c118efda7dc0a65ba84cd77885699ec8fc Reviewed-on: https://go-review.googlesource.com/30077 Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org> Run-TryBot: Brad Fitzpatrick <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org>
Also remove some stale TODOs and finish one of the TODOs, ignoring more incoming frames when the connection is in GOAWAY mode. Also, fix independently-broken transport test from a change in std: https://golang.org/cl/31595 Updates golang/go#14204 Change-Id: Iae8b02248464d613979c30d8f86eacb329cd262f Reviewed-on: https://go-review.googlesource.com/31727 Reviewed-by: Ian Lance Taylor <email@example.com> Run-TryBot: Brad Fitzpatrick <firstname.lastname@example.org>
…meout Updates #14204 Updates #16450 Updates #16100 Change-Id: Ic283bcec008a8e0bfbcfd8531d30fffe71052531 Reviewed-on: https://go-review.googlesource.com/32024 Reviewed-by: Tom Bergan <email@example.com> Reviewed-by: Brad Fitzpatrick <firstname.lastname@example.org> Run-TryBot: Brad Fitzpatrick <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org>
This makes ConfigureServer initialize the http2 Server's IdleTimeout from the http1 Server configuration, using the same rules as IdleTimeout in Go 1.8: first use IdleTimeout if specified, else fall back to the old ReadTimeout. Updates golang/go#14204 Change-Id: I4dee971f8416ef0cbf99335a199c46355f9ab09d Reviewed-on: https://go-review.googlesource.com/32230 Run-TryBot: Brad Fitzpatrick <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Tom Bergan <email@example.com> Reviewed-by: Brad Fitzpatrick <firstname.lastname@example.org>
This is an alternate implementation of https://golang.org/cl/32230 which is nicer to the dead code elimination in Go's linker. The old implementation causes a test in the net/http package to fail: https://storage.googleapis.com/go-build-log/2c24cf88/linux-amd64_39728ac9.log ... since it caused the cmd/go binary to link in the whole http1 & http2 Server code, due to the init func and slice which referenced those symbols. Instead, use an explicit func. This aso includes the tests meant to be in CL 32230 but which I'd failed to git add earlier. Updates golang/go#14204 Change-Id: I13dc138bf0c4df65bc282133ee94036b7f84ab70 Reviewed-on: https://go-review.googlesource.com/32323 Run-TryBot: Brad Fitzpatrick <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Martin Möhrmann <email@example.com>