Commit Graph

2107 Commits

Author SHA1 Message Date
Ian Lance Taylor
e883daec58 README: don't recommend go get
These days people will just import the packages and the go tool will
do the right thing. We don't need to explain it.

Add a pointer to the git repo, though.

For golang/go#62645

Change-Id: Ia5a16d8d66395e3feee2029ea1c3140b4d3939e7
Reviewed-on: https://go-review.googlesource.com/c/net/+/624175
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-11-01 18:28:29 +00:00
Carlana Johnson
511cc3a406 html: add Node.{Ancestors,ChildNodes,Descendants}()
Adds iterators for the parents, immediate children, and all children of a Node respectively.

Fixes golang/go#62113

Change-Id: Iab015872cc3a20fe5e7cae3bc90b89cba68cc3f8
GitHub-Last-Rev: d99de580ab
GitHub-Pull-Request: golang/net#215
Reviewed-on: https://go-review.googlesource.com/c/net/+/594195
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-10-29 04:13:16 +00:00
Damien Neil
4783315416 http2: limit 1xx based on size, do not limit when delivered
Replace Transport's limit of 5 1xx responses with a limit based
on the maximum header size: The total size of all 1xx response
headers must not exceed the limit we use on the size of the
final response headers.

(This differs slightly from the corresponding HTTP/1 change,
which imposes a limit on all 1xx response headers *plus* the
final response headers. The difference isn't substantial,
and this implementation fits better with the HTTP/2 framer.)

When the user is reading 1xx responses using a Got1xxResponse
client trace hook, disable the limit: Each 1xx response is
individually limited by the header size limit, but there
is no limit on the total number of responses. The user is
responsible for imposing a limit if they want one.

For golang/go#65035

Change-Id: I9c19dbf068e0f580789d952f63113b3d21ad86fc
Reviewed-on: https://go-review.googlesource.com/c/net/+/615295
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-10-21 20:13:47 +00:00
cuishuang
5716b9813d internal/socket: execute gofmt
Change-Id: Ifc793d535c31da3ba183ee44e1808e0072d7f099
Reviewed-on: https://go-review.googlesource.com/c/net/+/619595
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-10-11 22:36:55 +00:00
Damien Neil
42b1186360 http2: support ResponseController.EnableFullDuplex
The ResponseController.EnableFullDuplex method indicates that an HTTP
handler intends to interleave reads from a request body with writes
to the response body.

Add an EnableFullDuplex method to the ResponseWriter so we don't
return a not-supported error. The HTTP/2 server always supports
full duplex, so this is a no-op.

For golang/go#57786

Change-Id: I6529e6ce01d59b8b48fb67ba7c244255df57c174
Reviewed-on: https://go-review.googlesource.com/c/net/+/472717
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Дарья Бочкар <dasha7vanya@gmail.com>
2024-10-10 22:34:18 +00:00
Gopher Robot
6cc5ac4e9a go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I57613519f6e5795e60d258865e81f6954d672606
Reviewed-on: https://go-review.googlesource.com/c/net/+/617959
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.30.0
2024-10-04 16:20:59 +00:00
Mathias Fredriksson
f88258d67e websocket: update nhooyr.io/websocket to github.com/coder/websocket
Maintenance of nhooyr.io/websocket has moved to github.com/coder/websocket.

Read more about the transition at https://coder.com/blog/websocket

Updates golang/go#18152

Change-Id: Ia2b11c9a57ad7ded775b50a5bbb7ea91562d39b5
GitHub-Last-Rev: 59cea5e101
GitHub-Pull-Request: golang/net#222
Reviewed-on: https://go-review.googlesource.com/c/net/+/614075
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-09-25 22:53:10 +00:00
Damien Neil
7191757bc6 http2: add support for net/http HTTP2 config field
For golang/go#67813

Change-Id: I6b7f857d6ed250ba8b09649730980a91b3e8d7e9
Reviewed-on: https://go-review.googlesource.com/c/net/+/607255
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-09-25 18:02:06 +00:00
Damien Neil
4790dc7047 http2: add support for server-originated pings
Add configurable support for health-checking idle connections
accepted by the HTTP/2 server, following the same configuration
as the Transport.

Fixes golang/go#67812

Change-Id: Ia4014e691546b2c29db8dad3af5f39966d0ceb93
Reviewed-on: https://go-review.googlesource.com/c/net/+/601497
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-25 18:00:35 +00:00
Damien Neil
541dbe58b6 http2: add Server.WriteByteTimeout
Transports support a WriteByteTimeout option which sets the maximum
amount of time we can go without being able to write any bytes to
a connection. Add an equivalent option to Server for consistency.

Fixes golang/go#61777

Change-Id: Iaa8a69dfc403906eb224829320f901e5a6a5c429
Reviewed-on: https://go-review.googlesource.com/c/net/+/601496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-09-23 22:06:05 +00:00
Carlos Hernandez
3c333c0c52 route: fix address parsing of messages on Darwin
sizeofSockaddrInet is 16, but first byte of sockaddr specifies actual
size of sockaddr.

Although, 16 works for most cases, it fails for Netmasks addresses. On
Darwin only the significant bits of the netmask are in the msg.

Take this route message as an example

```
// rt_msg_hdr
88 00 05 01 00 00 00 00
41 08 00 00 07 00 00 00
92 7b 00 00 01 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00

// metrics
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00

// SOCKADDRS - DST  (100.113.0.0)
10 02 00 00 64 71 00 00
00 00 00 00 00 00 00 00

// GW  utun4319
14 12 21 00 01 08 00 00
75 74 75 6e 34 33 31 39
00 00 00 00

// NETMASK 255.255.0.0
06 02 00 00 ff ff

// NULL
00 00
```

i.e. ipv4
```
06 02 00 00 ff ff
```

The above byte sequence is for a sockaddr that is 6 bytes long
representing an ipv4 for address that is 255.255.0.0.

i.e. ipv6 netmask
```
0e 1e 00 00 00 00 00 00 ff ff ff ff ff ff 00 00
```

The above is `/48` netmask that should also be parsed using `b[0]` of the
sockaddr that contains the length.

Confirmed by using `route monitor`.

sources:
https://github.com/apple/darwin-xnu/blob/main/bsd/net/route.h
https://github.com/apple/darwin-xnu/blob/main/bsd/sys/socket.h#L603

Fixes golang/go#44740

Change-Id: I8153130d02d0a5e547fbf60a85762d3889e1d08c
GitHub-Last-Rev: f7b9253061
GitHub-Pull-Request: golang/net#220
Reviewed-on: https://go-review.googlesource.com/c/net/+/609577
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-09-06 18:26:58 +00:00
Gopher Robot
35b4abaed9 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I4be730755989f3d982deaac30cf72c1f3546d4b7
Reviewed-on: https://go-review.googlesource.com/c/net/+/611198
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.29.0
2024-09-05 16:43:33 +00:00
Dmitri Shuralyov
9bf379fa3e websocket: fix printf(var) mistake detected by latest printf checker
For golang/go#69267.

Change-Id: Ica6d123312495966ad6d222d67944fd602216853
Reviewed-on: https://go-review.googlesource.com/c/net/+/610799
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04 22:19:48 +00:00
Gopher Robot
4542a42604 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I6a2e43cca79f719c018887e1d75b578fc27be8f1
Reviewed-on: https://go-review.googlesource.com/c/net/+/603399
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
v0.28.0
2024-08-06 17:39:36 +00:00
ghosind
765c7e89b3 xsrftoken: create no padding base64 string by RawURLEncoding
The XSRF token generation function creates the padded base64 string by
base64.URLEncoding, then removes the padding. It is equivalent to the
base64.RawURLEncoding but with more costs.

Change-Id: I9cf5ad94e9cf3dca9bbfc1b6818ab07d41acf417
GitHub-Last-Rev: a8263b543c
GitHub-Pull-Request: golang/net#217
Reviewed-on: https://go-review.googlesource.com/c/net/+/599895
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Damien Neil <dneil@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-07-22 18:18:19 +00:00
Russ Cox
032e4e4358 LICENSE: update per Google Legal
Very minor tweaks:
 - Remove (c) pseudosymbol.
 - Remove "All Rights Reserved."
 - Change "Google Inc." (no longer exists) to "Google LLC".

[git-generate]
echo '
,s/\(c\) //
,s/ All rights reserved.//
,s/Google Inc./Google LLC/
w
q
' | sam -d LICENSE

Change-Id: Ibaa49e00dd08950a577e4343bfc574980d327995
Reviewed-on: https://go-review.googlesource.com/c/net/+/598579
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-07-16 16:05:10 +00:00
Gopher Robot
e2310ae9eb go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ibb0ab46488252d035430a654eed5dd4caab7509e
Reviewed-on: https://go-review.googlesource.com/c/net/+/596895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.27.0
2024-07-05 13:12:46 +00:00
Richard Miller
77708f716e quic: skip tests which depend on unimplemented UDP functions on Plan 9
The ReadMsgUDP and WriteMsgUDP methods of UDPConn are not implemented
(yet?) on Plan 9. Skip tests which require them.

Fixes golang/go#68288

Change-Id: Ic6c81b19322d589c10b16da61e9b89284294be05
Reviewed-on: https://go-review.googlesource.com/c/net/+/596795
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-07-05 10:47:41 +00:00
Damien Neil
9617c6335b http2: avoid Transport hang with Connection: close and AllowHTTP
CL 111835 changed Transport stream ID numbering to start at
stream 3 when AllowHTTP is set. This was based on a
misunderstanding:

When a connection upgrades an HTTP/1.1 request to HTTP/2,
the initial HTTP/1.1 request occupies stream 1.
However, Transport does not perform HTTP protocol upgrades.
When using a Transport to send unencrypted HTTP/2 requests,
the entire connection uses HTTP/2, the first request is
sent as HTTP/2, and there is no reason not to use stream 1
for this request.

Starting from stream 3 is mostly harmless,
but ClientConn.idleStateLocked assumes that client streams
start from 1. This causes it to misidentify new single-use
connections as having already sent a request (when AllowHTTP
is set), and therefore not suitable for use.

Revert to always starting stream IDs at 1.

Fixes golang/go#67671

Change-Id: I97c89de4ae49623d916f9dbd200f8252d2fd4247
Reviewed-on: https://go-review.googlesource.com/c/net/+/591275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-06-12 20:39:16 +00:00
Gopher Robot
66e838c6fb go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I472c3d990ea3c7c88a92bc0824034b112cec0eff
Reviewed-on: https://go-review.googlesource.com/c/net/+/590237
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.26.0
2024-06-04 17:07:48 +00:00
Damien Neil
6249541f2a http2: avoid race in server handler SetReadDeadine/SetWriteDeadline
Can't safely access responseWriter.rws from on the server's serve loop.

Change-Id: I477abe58cf9dd23813a0c5507aed2319696fdfaf
Reviewed-on: https://go-review.googlesource.com/c/net/+/589856
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-03 20:27:50 +00:00
Damien Neil
603e3e6390 quic: disable X25519Kyber768Draft00 in tests
Enabling this bloats the TLS handshake so flights no longer
fit in a single datagram. Disable it in tests. Add a test
using the crypto/tls defaults, to ensure we do handshake
properly with them.

Fixes golang/go#67783

Change-Id: I521188e7b5a313e9289e726935e5b26994090b4a
Reviewed-on: https://go-review.googlesource.com/c/net/+/589855
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-03 16:01:40 +00:00
Damien Neil
67e8d0c95d http2: report an error if goroutines outlive serverTester tests
Change-Id: Icd2152b4bddacf12120be16c32c8c2d52d235fbd
Reviewed-on: https://go-review.googlesource.com/c/net/+/589075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-30 19:56:53 +00:00
Damien Neil
56082791fe http2: avoid corruption in priority write scheduler
When removing a stream containing children in the priority
tree, it was possible for some children to not be correctly
moved to the parent of the removed stream.

Fixes golang/go#66514

Change-Id: Ie8a8743a6213a6b1a2426e023111878afff78f9e
Reviewed-on: https://go-review.googlesource.com/c/net/+/589255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-30 19:26:57 +00:00
Damien Neil
0d515a535e http2: factor out frame read/write test functions
Client and server tests both write frames to a test connection
and read frames back. Frame reads are usually paired with
test expectations.

Unify the API used for frame reads/writes in tests.

Introduce a testConnFramer type that implements a common set
of read/write methods, and embed it in both client and server
test types.

Change-Id: I6927c43459ba24f150a21c058a92797754f82bf1
Reviewed-on: https://go-review.googlesource.com/c/net/+/586249
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-28 22:41:32 +00:00
Damien Neil
9f5b79b000 http2: drop unused retry function
Change-Id: Ibe7e022a4863c8b0e502d7952b870046443acf7e
Reviewed-on: https://go-review.googlesource.com/c/net/+/586248
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-05-28 22:41:19 +00:00
Damien Neil
03c24c2d76 http2: use synthetic time in server tests
Change newServerTester to return a server using fake time
and a fake net.Conn.

Change-Id: I9d5db0cbe75696aed6d99ff1cd2369c2dea426c3
Reviewed-on: https://go-review.googlesource.com/c/net/+/586247
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-28 22:41:08 +00:00
Damien Neil
022530c415 http2: add a more full-featured test net.Conn
Add a net.Conn implementation that plays nicely with testsyncGroup,
implements read/write timeouts, and gives control over buffering
to let us write tests that cause writes to a Conn to block at
specific points in time.

Change-Id: I9d870b211ac9d938a8c4a221277981cdb821a6e4
Reviewed-on: https://go-review.googlesource.com/c/net/+/586246
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-21 22:48:04 +00:00
Damien Neil
410d19ee56 http2: avoid racy access to clientStream.requestedGzip
clientStream.requestedGzip is set from clientStream.writeRequest,
and examined by clientConn.readLoop. I'm not sure if there's
any possible way for an actual data race to happen here in
practice, since the read loop should only examine the field
after the request is sent by writeRequest, but it's enough
for the race detector to complain.

Set the field in ClientConn.roundTrip instead, before
the clientStream has become accessible to any other goroutines.

No test, but a following CL has race detector failures without
this change.

Change-Id: Id30f1b95bcfcc35c213440e0e47cce3feaaff06d
Reviewed-on: https://go-review.googlesource.com/c/net/+/586245
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-21 22:20:24 +00:00
Damien Neil
332fe235e6 http2: remove spec coverage test
When run with -coverspec, tests track which portions of the
specification they cover and the TestSpecCoverage test produces
an error if any sections lack test coverage.

This is a lovely idea, and perhaps we should resurrect it at
some point, but there is currently exactly one coverage
annotation, dating back to the first commit of this package.

Change-Id: I5d2d8a1032b783d113ed0982f7e97a3bd1c07a33
Reviewed-on: https://go-review.googlesource.com/c/net/+/586243
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-21 22:20:14 +00:00
Damien Neil
c1f5833288 all: replace deprecated io/ioutil calls
The io/ioutil package's features were moved to
the io and os packages in Go 1.16.

x/net depends on Go 1.18. Drop ioutil calls,
so gopls doesn't warn about them.

Change-Id: Ibdb576d94f250808ae285aa142e2fd41e7e9afc9
Reviewed-on: https://go-review.googlesource.com/c/net/+/586244
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-21 19:59:00 +00:00
Damien Neil
9545aeae37 http2: clearer distinction between test server types
newServerTester is used to create an HTTP/2 server for testing.
It returns a *serverTester, which includes a number of methods
for sending frames to and reading frames from a server connection
under test.

Many tests also use newServerTester to simply start an
*httptest.Server. These tests pass an "optOnlyServer" to
indicate that they don't need a client connection to interact with.
They interact with the *httptest.Server, and use no methods or
fields of *serverTester.

Make a clearer distinction between test types.

Add a newTestServer function which starts and returns
an *httptest.Server.

This function replaces use of newServerTester with optOnlyServer.

Change-Id: Ia590c9b4dcc23c17e530b0cc273b9120965da11a
Reviewed-on: https://go-review.googlesource.com/c/net/+/586155
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-20 20:54:17 +00:00
Damien Neil
b1ec120c3e http2: use implicit synchronization in tests
Rewrite the synchronization used in Transport tests.
This replaces the explicit synchronization, which requires
annotating every point where a goroutine in the code under test
may block, with implicit syncronization based on parsing
goroutine stacks to identify when all goroutines of interest are
blocked.

Change-Id: I02646e2752c359ed1b08126370a48f3d3c1fde77
Reviewed-on: https://go-review.googlesource.com/c/net/+/584895
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-20 20:54:10 +00:00
Tobias Klauser
49bf2d7d05 proxy: use strings.TrimSuffix
Change-Id: Icca4cdbdc1fb964eda8e0fed559f8d4e5dc45073
Reviewed-on: https://go-review.googlesource.com/c/net/+/586115
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-20 19:51:47 +00:00
Andy Pan
c87a5b62e2 http2: set up the timer of closing idle connection after the initialization
Fixes golang/go#66763

Change-Id: I046028b6072a6da77e7f1b4d1f2e6b14f8edb042
Reviewed-on: https://go-review.googlesource.com/c/net/+/578115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-05-16 22:34:05 +00:00
Damien Neil
8aa6dbf491 http2: cancel handler context on stream errors
When we reset a stream due to an error, cancel the handler context.

Fixes golang/go#67036

Change-Id: I66941d9bffb35d8b4358ff8d85cc784c1846afa6
Reviewed-on: https://go-review.googlesource.com/c/net/+/585595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-15 22:50:28 +00:00
Damien Neil
2c14f519f3 http2: drop the gate type
Drop a trivial "gate" type used in exactly one location,
replacing it with an equivalent channel operation.

We've been using a "gate" with a different definition in
the quic package; dropping this hapax legomenon type from
the http2 package frees up the name if we want to use the
same gate here.

Change-Id: Id9c7d05daf7ee920c38090df960822fcc1168a4d
Reviewed-on: https://go-review.googlesource.com/c/net/+/584896
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-13 18:16:53 +00:00
vvatanabe
ac99879962 webdav: return 409 for PUT without parent collection
Aligning with the WebDAV RFC specification,
changes the server response for PUT operations that would
create a resource without an existing parent collection
from HTTP 404 Not Found to HTTP 409 Conflict.

RFC RFC4918, section 9.7.1

Fixes golang/go#67150

Change-Id: I5ce6c5ea147a6a450ef5ae2e0077eb0dce409743
Reviewed-on: https://go-review.googlesource.com/c/net/+/583055
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-05-10 17:25:32 +00:00
Damien Neil
7fa635bd26 http2: avoid panic on h2c upgrade failure
When performing an h2c upgrade, we would panic if an error occurred
reading the client preface. *serverConn.closeStream assumes that
a conn with an IdleTimeout > 0 will have an idleTimer, but in the
h2c upgrade case the stream may have been created before the timer.

Fixes golang/go#67168

Change-Id: I30b5a701c10753ddc344079b9498285f099155cf
Reviewed-on: https://go-review.googlesource.com/c/net/+/584255
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-08 17:52:51 +00:00
Gopher Robot
d27919b57f go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: If4b46b8a597f56ee25582b456ee4ac5f42e3fdd4
Reviewed-on: https://go-review.googlesource.com/c/net/+/583516
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.25.0
2024-05-06 16:24:48 +00:00
Tobias Klauser
e0324fcdb5 http2: use net.ErrClosed
Use errors.Is(err, net.ErrClosed) instead of checking for a known
string. net.ErrClosed is available since Go 1.16, the current minimum
version in go.mod is Go 1.18.

For golang/go#4373

Change-Id: Id98771874434bae7d9c6d1d4d36fddb28822eb39
Reviewed-on: https://go-review.googlesource.com/c/net/+/583016
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-06 15:32:06 +00:00
Damien Neil
b20cd5933a quic: initiate key rotation earlier in connections
The QUIC interop runner "keyrotate" test requires that the client
initiate a key rotation early in the connection. With our current
ack frequency, it seems that we need to rotate within the first
300-400 packets for the test to pass.

Reduce the initial key rotation from 1000 to 100 packets.
Rotating earlier shouldn't have any real downsides
(rotation is cheap and generally done once per connection,
except for very long-lived connections), and this is simpler
than providing a way to tune the rotation interval in one
specific test.

For golang/go#67138

Change-Id: I33d47ea35ed39f0a13c171adb2b0698f8c93050e
Reviewed-on: https://go-review.googlesource.com/c/net/+/582855
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-03 21:52:40 +00:00
Eng Zer Jun
f95a3b3a48 html: fix typo in package doc
Change-Id: I3cacfadc0396c8ef85addd062d991bb6f5b0483a
Reviewed-on: https://go-review.googlesource.com/c/net/+/580035
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-04-18 22:01:12 +00:00
Julien Cretel
0a24555f5c http/httpguts: speed up ValidHeaderFieldName
Eliminate bounds checks and eschews UTF-8 decoding in ValidHeaderFieldName,
thereby doubling its speed without introducing any allocations.
Also eliminate bounds checks in IsTokenRune.

Add tests and benchmarks for both ValidHeaderFieldName and IsTokenRune.

goos: darwin
goarch: amd64
pkg: golang.org/x/net/http/httpguts
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                       │   before    │                after                │
                       │   sec/op    │   sec/op     vs base                │
IsTokenRune-8            315.2n ± 0%   316.2n ± 1%        ~ (p=0.245 n=20)
ValidHeaderFieldName-8   62.77n ± 0%   29.16n ± 0%  -53.55% (p=0.000 n=20)
geomean                  140.7n        96.02n       -31.73%

                       │    before    │                after               │
                       │     B/op     │    B/op     vs base                │
IsTokenRune-8            0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20)
ValidHeaderFieldName-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20)
geomean                             ²               +0.00%

                       │    before    │                after               │
                       │  allocs/op   │ allocs/op   vs base                │
IsTokenRune-8            0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20)
ValidHeaderFieldName-8   0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=20)
geomean                             ²               +0.00%

Fixes golang/go#66700

Change-Id: Ia3ea80e5f0d173e3a69eb7429023587fd7bc5933
GitHub-Last-Rev: 1f1d25d1ec
GitHub-Pull-Request: golang/net#207
Reviewed-on: https://go-review.googlesource.com/c/net/+/578075
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-15 20:43:53 +00:00
Damien Neil
ec05fdcd71 http2: don't retry the first request on a connection on GOAWAY error
When a server sends a GOAWAY frame, it indicates the ID of the
last stream it processed. We use this to mark any requests after
that stream as being safe to retry on a new connection.

Change this to not retry the first request on a connection if we
get a GOAWAY with an error, even if the GOAWAY has a stream ID
of 0 indicating that it didn't process that request.
If we're getting an error as the first result on a new connection,
then there's either something wrong with the server or something
wrong with our request; either way, retrying isn't likely to be
productive and may be unsafe.

This matches the behavior of the HTTP/1 client, which
also avoids retrying the first request on a new connection.

For golang/go#66668
Fixes golang/go#60636

Change-Id: I90ea7cfce2974dd413f7cd8b78541678850376a5
Reviewed-on: https://go-review.googlesource.com/c/net/+/576895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-04-05 22:13:09 +00:00
Damien Neil
b67a0f0535 http2: send correct LastStreamID in stream-caused GOAWAY
When closing a connection because a stream contained a request we
didn't like (for example, because the request headers exceed
the maximum we will accept), set the LastStreamID in the GOAWAY
frame to include the offending stream. This informs the client
that retrying the request is unlikely to succeed, and avoids
retry loops.

This change requires passing the stream ID of the offending
stream from Framer.ReadFrame up to the caller. The most sensible
way to do this would probably be in the error. However,
ReadFrame currently returns a defined error type for
connection-ending errors (ConnectionError), and that type is a
uint32 with no place to put the stream ID. Rather than changing
the returned errors, ReadFrame now returns an error along with
a non-nil Frame containing the stream ID, when a stream is
responsible for a connection-ending error.

For golang/go#66668

Change-Id: Iba07ccbd70ab4939aa56903605474d01703ac6e4
Reviewed-on: https://go-review.googlesource.com/c/net/+/576756
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-05 15:01:38 +00:00
Damien Neil
a130fcc1c1 quic: don't consider goroutines running when tests start as leaked
Change-Id: I138e284ee74c9402402f564d25e50ab753c51e9e
Reviewed-on: https://go-review.googlesource.com/c/net/+/576536
Reviewed-by: Chressie Himpel <chressie@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-04 20:10:37 +00:00
Gopher Robot
7bbe32058a go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I288208575b5d913be9a8b4ec87df5ca9753de151
Reviewed-on: https://go-review.googlesource.com/c/net/+/576516
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
v0.24.0
2024-04-04 19:16:58 +00:00
Damien Neil
c48da13158 http2: fix TestServerContinuationFlood flakes
This test causes the server to send a GOAWAY and close a connection.
The server GOAWAY path writes a GOAWAY frame asynchronously, and
closes the connection if the write doesn't complete within 1s.
This is causing failures on some builders, when the frame write
doesn't complete in time.

The important aspect of this test is that the connection be closed.
Drop the check for the GOAWAY frame.

Change-Id: I099413be9c4dfe71d8fe83d2c6242e82e282293e
Reviewed-on: https://go-review.googlesource.com/c/net/+/576235
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.23.0
2024-04-03 17:30:20 +00:00
Ian Lance Taylor
762b58d1cf http2: fix tipos in comment
Change-Id: I20cd0f8db534fe2a849306eb7e0c8ee5b434e88f
Reviewed-on: https://go-review.googlesource.com/c/net/+/576175
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-04-03 16:50:56 +00:00