664 Commits

Author SHA1 Message Date
Damien Neil
978cfadd31 http2: avoid blocking while holding ClientConn.mu
Operations which examine the state of a ClientConn--notably,
the connection pool's check to see if a conn is available to
take a new request--need to acquire mu. Blocking while holding mu,
such as when writing to the network, blocks these operations.

Remove blocking operations from the mutex.
Perform network writes with only ClientConn.wmu held.
Clarify that wmu guards the per-conn HPACK encoder and buffer.

Add a new mutex guarding request creation, covering the critical
section starting with allocating a new stream ID and continuing
until the stream is created.

Fix a locking issue where trailers were written from the HPACK
buffer with only wmu held, but headers were encoded into the buffer
with only mu held. (Now both encoding and writes occur with wmu
held.)

Fixes golang/go#32388.
Fixes golang/go#48340.

Change-Id: Ibb313424ed2f32c1aeac4645b76aedf227b597a3
Reviewed-on: https://go-review.googlesource.com/c/net/+/349594
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-17 22:17:30 +00:00
Brad Fitzpatrick
95888ee714 http2: add Transport.CountErrors
Like the earlier Server.CountErrors. This lets people observe hook up
an http2.Transport to monitoring (expvar/Prometheus/etc) and spot
pattern changes over time.

Change-Id: I12a4d0b3499fb0be75d5a56342ced0719c00654d
Reviewed-on: https://go-review.googlesource.com/c/net/+/350709
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-17 21:38:27 +00:00
Brad Fitzpatrick
3c21e5b277 http2: add Server.CountError hook for error metrics
Change-Id: Ieaa2e97a2c467a3cf0753fcbf1a143f7bf76ef29
Reviewed-on: https://go-review.googlesource.com/c/net/+/350649
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-09-17 16:35:49 +00:00
Heschi Kreinick
12bc252f5d http/h2demo: remove node selector
For golang/go#48408.

Change-Id: I11f4c4ed317b06297e22c98b98ab529e15f7bd2f
Reviewed-on: https://go-review.googlesource.com/c/net/+/350140
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-09-16 01:41:20 +00:00
Damien Neil
943fd674d4 http2: fix off-by-one error in client check for max concurrent streams
Fixes golang/go#48358.

Change-Id: Ib4eb93702b32ae7d03cad17ca0b997d5e6a58ad7
Reviewed-on: https://go-review.googlesource.com/c/net/+/349490
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-13 18:02:22 +00:00
Damien Neil
7bf0baf339 http2: close request body after early RoundTrip failures
The RoundTrip contract requires that the request Body be closed,
even when an error occurs sending the request.

Fix several cases where the body was not closed by hoisting the
Close call to Transport.RoundTripOpt. Now ClientConn.roundTrip
takes responsibility for closing the body once the body write
begins; otherwise, the caller does so.

Fix the case where a new body is acquired via Request.GetBody
to close the previous body, matching net/http's behavior.

Fixes golang/go#48341.

Change-Id: Id9dc682d4d86a1c255c7c0d864208ff76ed53eb2
Reviewed-on: https://go-review.googlesource.com/c/net/+/349489
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-13 18:01:05 +00:00
Heschi Kreinick
a5e095526f http2/h2demo: set prod namespace for deploy
Forgot to do this.

Change-Id: I74a4f53047c99825005d323b6c70d4215e5cb8ea
Reviewed-on: https://go-review.googlesource.com/c/net/+/348589
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-08 19:18:46 +00:00
Heschi Kreinick
ff17edfbf2 http/h2demo: move to Workload Identity
Create a new service account, and move the deployment over to the prod
namespace.

Change-Id: If91ca021aeeeaaa7994670d103f0b30c232c0e85
Reviewed-on: https://go-review.googlesource.com/c/net/+/348169
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-09-07 22:56:31 +00:00
Steven Hartland
f8bed21638 http2: limit client initial MAX_CONCURRENT_STREAMS
Prevent the client trying to establish more streams than the server is willing to accept during the initial life time of a connection by limiting `maxConcurrentStreams` to `100`, the http2 specifications
recommended minimum, until we've received the initial `SETTINGS` frame from the server.

After a `SETTINGS` frame has been received use the servers `MAX_CONCURRENT_STREAMS`, if present, otherwise use `1000` as a reasonable value.

For normal consumers this will have very little impact, allowing a decent level of concurrency from the start, and for highly concurrent consumers or large bursts it will prevent significant number of rejected streams being attempted hence actually increasing performance.

Fixes golang/go#39389

Change-Id: I35fecd501ca39cd059c7afd1d44090b023f16e1e
GitHub-Last-Rev: 0d1114d3a5
GitHub-Pull-Request: golang/net#73
Reviewed-on: https://go-review.googlesource.com/c/net/+/236497
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-07 21:54:12 +00:00
Brad Fitzpatrick
ad29c8ab02 http2: make Transport not reuse conns after a stream protocol error
If a server sends a stream error of type "protocol error" to a client,
that's the server saying "you're speaking http2 wrong". At that point,
regardless of whether we're in the right or not (that is, regardless of
whether the Transport is bug-free), clearly there's some confusion and
one of the two parties is either wrong or confused. There's no point
pushing on and trying to use the connection and potentially exacerbating
the confusion (as we saw in golang/go#47635).

Instead, make the client "poison" the connection by setting a new "do
not reuse" bit on it. Existing streams can finish up but new requests
won't pick that connection.

Also, make those requests as retryable without the caller getting an
error.

Given that golang/go#42777 existed, there are HTTP/2 servers in the
wild that incorrectly set RST_STREAM PROTOCOL_ERROR codes. But even
once those go away, this is still a reasonable fix for preventing
a broken connection from being stuck in the connection pool that fails
all future requests if a similar bug happens in another HTTP/2 server.

Updates golang/go#47635

Change-Id: I3f89ecd1d3710e49f7219ccb846e016eb269515b
Reviewed-on: https://go-review.googlesource.com/c/net/+/347033
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-09-03 16:21:42 +00:00
Damien Neil
8d991716f6 http2: accept zero-length block fragments in HEADERS frames
Fix a fencepost error which rejects HEADERS frames with neither
payload nor padding, but accepts ones with padding and no payload.

Fixes golang/go#47851.

Change-Id: Ic6ed65571366e86980a5ec69e7f9e6ab958f3b07
Reviewed-on: https://go-review.googlesource.com/c/net/+/344029
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-09-02 16:59:21 +00:00
Michael Fraenkel
e898025ed9 http2: close the request body if needed
As per client.Do and Request.Body, the transport is responsible to close
the request Body.
If there was an error or non 1xx/2xx status code, the transport will
wait for the body writer to complete. If there is no data available to
read, the body writer will block indefinitely. To prevent this, the body
will be closed if it hasn't already.
If there was a 1xx/2xx status code, the body will be closed eventually.

Updates golang/go#43989

Change-Id: I9a4a5f13658122c562baf915e2c0c8992a023278
Reviewed-on: https://go-review.googlesource.com/c/net/+/323689
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-25 18:34:10 +00:00
Michael Fraenkel
60bc85c4be http2: complete outstanding async write before reading the next frame
For golang/go#42777

Change-Id: I8d7e35ded3fe508f6c285e84ba768104c3406bdf
Reviewed-on: https://go-review.googlesource.com/c/net/+/330909
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-08-13 16:08:13 +00:00
Damien Neil
3a7c47852f http2: delete README
Out of date, redundant with package doc, just drop it.

Fixes golang/go#47624.

Change-Id: Ic4a686330d69744e57bf01785c53707ba29944b9
Reviewed-on: https://go-review.googlesource.com/c/net/+/341369
Trust: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-08-13 15:41:08 +00:00
Yasuhiro Matsumoto
c6fcb2dbf9 all: fix typos
Change-Id: Ie6cbdc214354a37887433a11b5f1f6adf9d047d3
Reviewed-on: https://go-review.googlesource.com/c/net/+/337209
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>
2021-07-26 21:34:35 +00:00
Heschi Kreinick
853a461950 http2/h2demo: add Autocert notification email
Add golang-dev as the Autocert notification email so Let's Encrypt can
send us emails. golang-dev is not an ideal choice, but we need something
publicly accessible and there isn't an obvious better option. My
understanding is we should expect essentially no emails so I don't want
to worry too much about it.

Updates golang/go#47108.

Change-Id: Ic3b5b7554d516ea2840bb56499eb3b8f35bf2304
Reviewed-on: https://go-review.googlesource.com/c/net/+/334929
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-07-16 20:39:47 +00:00
Brad Fitzpatrick
04defd469f http2: reduce frameScratchBuffer caching aggressiveness
Use a sync.Pool, not per ClientConn.

Co-authored with dneil@google.com

Fixes golang/go#38049

Change-Id: I93f06b19857ab495ffcf15d7ed2aaa2a6cb31515
Reviewed-on: https://go-review.googlesource.com/c/net/+/325169
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-14 18:27:18 +00:00
Filippo Valsorda
84b48f89b1 http2: check that Unicode-aware functions are not used
Change-Id: I366ba1f21c48773fa923e47501ccd7efb8c99a2d
Reviewed-on: https://go-review.googlesource.com/c/net/+/318430
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
2021-06-10 13:23:58 +00:00
Filippo Valsorda
52da8fb2a6 http2: also set "http/1.1" ALPN in ConfigureServer
With CL 289209, we started enforcing ALPN protocol overlap when both
sides support ALPN. This means that an "http/1.1"-only ALPN-aware client
will fail to connect to a server with only "h2" in NextProtos.
Unfortunately, that's how ConfigureServer was setting up the tls.Config.

The new behavior mirrors ConfigureTransport on the client side (but not
Transport.newTLSConfig because the latter is used to make HTTP/2-only
connections).

Updates golang/go#46310

Change-Id: Idbab7a6f873f3be78104df6f2908895f4d399bd3
Reviewed-on: https://go-review.googlesource.com/c/net/+/325611
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-06-10 12:43:26 +00:00
Roberto Clapis
81045d8b47 http2: switch to ASCII equivalents of string functions
The current implementation uses UTF-aware functions
like strings.EqualFold and strings.ToLower.

This could, in some cases, cause http smuggling.

Change-Id: I7250b24bbefe2143b61cc8dbbe2853a66499d829
Reviewed-on: https://go-review.googlesource.com/c/net/+/313489
Trust: Roberto Clapis <roberto@golang.org>
Trust: Katie Hockman <katie@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-05-10 09:51:57 +00:00
Filippo Valsorda
16afe75a67 http2: remove TLSConfig.CipherSuites order check
The order of CipherSuites is ignored as of Go 1.17, and the effective
order will always put good ciphers first, as tested by TestCipherSuites
in crypto/tls.

Updates golang/go#45430

Change-Id: I54424f68bffe805f504b57eb025601c08c6357f6
Reviewed-on: https://go-review.googlesource.com/c/net/+/314611
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-05-08 05:16:33 +00:00
Ian Lance Taylor
0714010a04 crypto/tls: don't use tls.Dialer on pre-Go1.15 systems
We have received many reports of build failures using Go 1.14,
enough to make it worth supporting that release even though it
is out of our support window.

For golang/go#45942
For golang/go#45943
For golang/go#45946
For golang/go#45950
For golang/go#45968

Change-Id: I9d6b1762ae622b3e9a5de5b1967264387166b1c7
Reviewed-on: https://go-review.googlesource.com/c/net/+/317069
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-05-05 21:49:59 +00:00
Johan Brandhorst
bbd867fde5 http2: use (*tls.Dialer).DialContext in dialTLS
This lets us propagate the request context into the TLS
handshake.

Related to CL 295370
Updates golang/go#32406

Change-Id: Ie10c301be19b57b4b3e46ac31bbe87679e1eebc7
Reviewed-on: https://go-review.googlesource.com/c/net/+/295173
Trust: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2021-05-04 13:21:25 +00:00
Tobias Klauser
5f58ad60dd ipv4: use type IPMreqn from x/sys/unix
Use the IPMreqn type and the SizeofIPMreqn defined in the
golang.org/x/sys/unix package instead of locally duplicating them.

Change-Id: I98768e01fd4b0d1018892d5ed49455366a7356bb
Reviewed-on: https://go-review.googlesource.com/c/net/+/312490
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-23 18:45:38 +00:00
Tobias Klauser
798c2154c5 ipv6: use all socket option consts from x/sys/unix
Remove the remaining local definitions of various socket option
constants and use the constants defined in the golang.org/x/sys/unix
package instead.

Change-Id: I110cf984e2bac5bf48d6e6489fd6da8ab7b13b10
Reviewed-on: https://go-review.googlesource.com/c/net/+/311749
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-20 21:01:06 +00:00
David Black
064579744e http2: update curl download location in Dockerfile
Change-Id: Ifeef1948df83f104396c43c15f07a2d146208533
GitHub-Last-Rev: c8e17d64d1
GitHub-Pull-Request: golang/net#99
Reviewed-on: https://go-review.googlesource.com/c/net/+/309949
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-14 19:42:28 +00:00
Tobias Klauser
afb366fc7c go.mod: bump golang.org/x/text to v0.3.6
Fixes golang/go#43983

Change-Id: I518aacabf11bdbc4013dcf46ef5bf1c10fa5720c
Reviewed-on: https://go-review.googlesource.com/c/net/+/308869
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-10 08:11:32 +00:00
Tobias Klauser
e57232859f go.mod: update golang.org/x/sys to v0.0.0-20210330210617-4fbd30eecc44
This fixes the build on freebsd/arm by pulling in missing MCAST_* consts
added in CL 305810.

Change-Id: Ib370beeb82f04d508b9c9278da32fa8e5268861c
Reviewed-on: https://go-review.googlesource.com/c/net/+/306069
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-03-30 23:05:44 +00:00
Tobias Klauser
3061449911 go.mod: update golang.org/x/sys to v0.0.0-20210324051608
This pulls in additional IP socket option constants.

Change-Id: If8029a621cc5f9fdb1abfdc84561a2969b61bfd6
Reviewed-on: https://go-review.googlesource.com/c/net/+/304329
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-24 20:56:11 +00:00
Tobias Klauser
d523dce5a7 ipv4, ipv6: use IP_* socket option constants from x/sys/windows
Use the IP_* socket option constants defined in the
golang.org/x/sys/windows package instead of defining them locally.

Change-Id: Ie6e79b7984795c409a01bd57134090bb720ea4b3
Reviewed-on: https://go-review.googlesource.com/c/net/+/301810
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-16 09:26:52 +00:00
Luke Shumaker
e18ecbb051 http2/h2c: Respect the req.Context()
When using h2c.NewHandler, the *http.Request object for h2c requests has a
.Context() that doesn't inherit from the *http.Server's BaseContext.  This
is surprising for users of vanilla net/http, and is surprising to users of
http2.ConfigureServer; HTTP/1 requests inherit from that BaseContext, and
TLS h2 requests inherit from that BaseContext, but cleartext h2c requests
don't.

So, modify h2c.NewHander to respect that base Context, by way of the
hijacked Request's .Context().

Change-Id: Ibc24ae6e2fb153d9561827ad791329487dae8e5a
GitHub-Last-Rev: 821b2070f7
GitHub-Pull-Request: golang/net#88
Reviewed-on: https://go-review.googlesource.com/c/net/+/278972
Reviewed-by: Liam Haworth <liam@haworth.id.au>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2021-02-26 17:20:49 +00:00
Ashish Bhate
39120d07d7 http2: discard DATA frames with higher stream IDs during graceful shutdown
If the server sends a GOAWAY at the same time that a client sends
HEADERS+DATA, the server will discard the HEADERS, but error on the DATA
frame. Luckily, the server doesn't turn this into a connection error
because it's already in a GOAWAY state. It just logs the PROTOCOL_ERROR,
but that produces a confusing log message.

This change effectively suppresses the log message by discarding the
DATA frame rather than erroring on it. Also, we now discard any frames for
streams with identifiers higher than the identified last stream. This is
done as per section 6.8 of the HTTP2 spec.

I also updated some stale documentation while I was trying to understand
the logic.

This is CL 188360 with a test

Fixes golang/go#32112

Co-authored-by: Yunchi Luo <mightyguava@gmail.com>
Co-authored-by: Michael Fraenkel <michael.fraenkel@gmail.com>

Change-Id: I612c2bd82e37551e813af0961b16a98d14e77c38
Reviewed-on: https://go-review.googlesource.com/c/net/+/237957
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Damien Neil <dneil@google.com>
2021-02-26 10:14:13 +00:00
Michael Fraenkel
9060382bd4 http2: rework Ping test to rely less on timing
Pings are either expected to occur, so count until you reach your goal
before a deadline, or they do not occur, and the deadline is exceeded.

Fixes golang/go#42514

Change-Id: If9ff19ed4954bee83ddeba83a4ac9c2d43f6e1c1
Reviewed-on: https://go-review.googlesource.com/c/net/+/269797
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-02-22 17:17:44 +00:00
Russ Cox
5f55cee0dc all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I5b2b7d93424e828a3c5f76ae3f30ab825aca388e
Reviewed-on: https://go-review.googlesource.com/c/net/+/294371
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-20 03:31:24 +00:00
Tobias Klauser
ac852fbbde http2/h2i: use x/term instead of x/crypto/ssh/terminal
The x/crypto/ssh/terminal package was moved to x/term in CL 258001 and
the implementation replaced by wrappers in CL 258003. Use x/term
directly to reduce dependencies.

Change-Id: I4cf50bde60f8534e633cb4989da342af279203ec
Reviewed-on: https://go-review.googlesource.com/c/net/+/275477
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-12-09 12:38:23 +00:00
Michael Fraenkel
5d6afe98e0 http2: send a nil error if we cancel a delayed body write
Once a request body is scheduled to be written, a result of the write is always
expected. If the body writer is cancelled, and the write was never started,
send a successful result.

The test included is a modified version of the TestNoSniffExpectRequestBody_h2 found
in net/http.

Updates golang/go#42498

Change-Id: If3f23993170bdf10e9ae4244ec13ae269bd3877a
Reviewed-on: https://go-review.googlesource.com/c/net/+/269058
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-12-01 19:55:09 +00:00
Michael Fraenkel
69a78807bb http2: remove the timeout since we don't know a good value
The test is expected to finish so rather than wait on some arbitrary
timeout, let the go test timeout show us where things went wrong.

Fixes golang/go#42381

Change-Id: Ia9405f9f75b2f5f73ed3f8a540a74b7c64066ad0
Reviewed-on: https://go-review.googlesource.com/c/net/+/267977
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-11-10 03:11:24 +00:00
Michael Fraenkel
a11eb1b685 http2: wait for both client and server funcs
When executing the clienttester.run(), it would exit when both
the client and server completed successfully or if either side failed.
If one side fails, the other side may not have finished. If an error was
reported, the goroutine was caught executing after the test completed.

The expectation is always that both sides complete successfully. In the
case where one side fails, we still need to wait for the other side to
complete.

Close both client and server connections on error to expedite the
completion.

Fixes golang/go#41299

Change-Id: If47fbe61de42495bb2b1327bd5b03d6c295670dc
Reviewed-on: https://go-review.googlesource.com/c/net/+/267760
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-11-09 17:26:40 +00:00
Michael Fraenkel
ff519b6c91 net/http2: wait until the request body has been written
When the clientConn is done with a request, if there is a request body,
we must wait until the body is written otherwise there can be a race
when attempting to rewind the body.

Fixes golang/go#31192
Fixes golang/go#41234

Change-Id: I77606cc19372eea8bbd8995102354f092b8042be
Reviewed-on: https://go-review.googlesource.com/c/net/+/253259
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-31 05:49:03 +00:00
billofarrell
146b70c837 all: add support for zos/s390x
This adds net support for zos/s390x. These changes should not affect other platforms.

Fixes golang/go#42130

Change-Id: Ia7faa29de76b7c5713120657b296106c2e27bfd2
Reviewed-on: https://go-review.googlesource.com/c/net/+/264028
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-26 09:15:29 +00:00
Michael Fraenkel
be3efd7ff1 net/http2: wait for test goroutines to complete
Don't assume goroutines are gone immediately. Any error that occurs will
cause a panic after the test completes.

Fixes golang/go#41299

Change-Id: I00d3e246fd0b265a33a5dc1a536a33866df30d75
Reviewed-on: https://go-review.googlesource.com/c/net/+/254278
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Chao Xu <xuchao@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-10-24 04:28:10 +00:00
Damien Neil
08b38378de http2: add ConfigureTransports
The ConfigureTransport function doesn't provide any way to get at the
http2 Transport it creates, making it impossible to configure transport
parameters such as ReadIdleTimeout.

Add a ConfigureTransports function which returns the http2 Transport.

The very similar names are unfortunate, but they'll sort next to each
other in godoc and the pluralized ConfigureTransports hints at its purpose:
it lets you configure both the http and http2 transports.

Fixes golang/go#40201.
Updates golang/go#41721.

Change-Id: I97aa345f369f49462c41d3f60d35660c06c51287
Reviewed-on: https://go-review.googlesource.com/c/net/+/264017
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-22 23:12:55 +00:00
Michael Fraenkel
f5854403a9 http2: close Transport connection on write errors
When a new connection is created, and a write error occurs during the
initial exchange, the connection must be closed. There is no guarantee
that the caller will close the connection.

When a connection with an existing write error is used or being used, it
will stay in use until its read loop completes. Requests will continue
to use this connection and fail when writing its header. These
connections should be closed to force the cleanup in its readLoop.

Fixes golang/go#39337

Change-Id: I45e1293309e40629531f4cbb69387864f4f71bc2
Reviewed-on: https://go-review.googlesource.com/c/net/+/240337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Trust: Damien Neil <dneil@google.com>
2020-10-21 03:54:29 +00:00
Radek Simko
a7d1128cca go.mod: bump golang.org/x/text to v0.3.3
This upgrades golang.org/x/text to 0.3.3 (which addresses CVE-2020-14040).

Change-Id: I39bbb1378a9dfe643032f3139e4bb3265b6befb8
GitHub-Last-Rev: 28e29fba21
GitHub-Pull-Request: golang/net#83
Reviewed-on: https://go-review.googlesource.com/c/net/+/254960
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
2020-10-06 15:34:59 +00:00
Tobias Klauser
3d0752d450 go.mod: update golang.org/x/sys to v0.0.0-20200930185726-fdedc70b468f
Make sure to get correct cmsg alignment for all platform, namely CL
258457 for netbsd/arm64.

In an upcoming CL, this repo will switch to use cmsg alignment funcs
from x/sys/unix.

Change-Id: I7aab54badcbfe363c8840ab3bbe0a45c589e4b1b
Reviewed-on: https://go-review.googlesource.com/c/net/+/259057
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2020-10-02 20:23:53 +00:00
Michael Fraenkel
5d4f700557 net/http2: send WINDOW_UPDATE on a body's write failure
When the body.Write fails during processData, the connection flow
control must be updated to account for the data received. The connection's
WINDOW_UPDATE should reflect the amount of data that was not successfully
written. The stream is about to be closed, so no update is required.

Fixes golang/go#40423

Change-Id: I546597cedf3715e6617babcb3b62140bf1857a27
Reviewed-on: https://go-review.googlesource.com/c/net/+/245158
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-27 03:25:02 +00:00
Paschalis Tsilias
62affa334b x/net/http2: reject HTTP/2 Content-Length headers containing a sign
Continuing the work of CL 234817, we enforce the same for HTTP/2
connections; that Content-Length header values with a sign (such as
"+5") are rejected or ignored. In each place, the handling of such
incorrect headers follows the approach already in place.

Fixes golang/go#39017

Change-Id: Ie4854962dd0091795cb861d1cb3a78ce753fd3a8
Reviewed-on: https://go-review.googlesource.com/c/net/+/236098
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-04 19:48:48 +00:00
Michael Fraenkel
c890458142 net/http2: fix erringRoundTripper
The http transport added a new interface to detect RoundTrippers that
always error. Prior to this, the erringRoundTripper would not be
identified as such and a new connection was always created.

Updates golang/go#40213

Change-Id: Icc315dcc9ce8ea0db94a1f2c58c6a741675d8962
Reviewed-on: https://go-review.googlesource.com/c/net/+/243257
Reviewed-by: Chris Friesen <cbf123@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-22 12:43:28 +00:00
Brad Fitzpatrick
4c52546033 all: update golang.org/x/crypto to v0.0.0-20200622213623-75b288015ac9
This pulls in a fix for CVE-2019-11840 and other improvements.

For golang/go#30965.

Change-Id: I20c2bd4a82bf6fe6bd4926bd0643cc57a45a242b
Reviewed-on: https://go-review.googlesource.com/c/net/+/239700
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-06-25 00:16:55 +00:00
Richard Miller
627f9648de x/net/http2: don't rely on TCP CloseWrite in tests on Plan 9
In TestTransportPingWhenReading, a TCP half-close was being used,
which isn't supported in the Plan 9 kernel. The workaround is to
call (*TCPConn).Close when running on Plan 9.

See golang/go#17906

Fixes golang/go#39233

Change-Id: Ifb2934621fb53d76a3b161b239c438c13f8c508e
Reviewed-on: https://go-review.googlesource.com/c/net/+/235217
Reviewed-by: David du Colombier <0intro@gmail.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-06-02 11:40:24 +00:00