Commit Graph

2296 Commits

Author SHA1 Message Date
Nicholas S. Husin
4e1c745a70 internal/http3: make Server response include headers that can be inferred
This CL makes Server automatically set certain headers in a response
when they can be inferred and have not been explicitly set in a handler.

For now, "Date" and "Content-Type" headers are supported. Note that
unlike HTTP/1 and HTTP/2, "Content-Length" header is not automatically
set.

For golang/go#70914

Change-Id: Ie8d64ee0efb10118dfcba7a156f6f6886f565046
Reviewed-on: https://go-review.googlesource.com/c/net/+/746760
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-23 16:04:38 -08:00
Konnyaku
19f580fd68 http2: fix nil panic in typeFrameParser for unassigned frame types
The addition of FramePriorityUpdate (0x10) in RFC 9218 introduced a gap
in the frameParsers array indices (0x0a-0x0f). These indices were
initialized to nil, causing a panic when typeFrameParser accessed them
for unassigned frame types (e.g., ALTSVC 0x0a).

This change adds a nil check in typeFrameParser to safely fallback to
parseUnknownFrame for these unassigned types, preventing the crash.

Fixes golang/go#77652

Change-Id: I14d7ad85afc1eafabc46417a9fff10f9e0a22446
Reviewed-on: https://go-review.googlesource.com/c/net/+/746180
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>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2026-02-17 11:57:01 -08:00
Nicholas S. Husin
818aad7ad4 internal/http3: add server to client trailer header support
This change implements support for Server to send trailer headers, and
for ClientConn to receive said trailer headers. This is just like
go.dev/cl/743600, but in the opposite direction.

The bulk of the implementation relies on the trailer header encoding and
decoding support that was added to bodyWriter and bodyReader
respectively in go.dev/cl/743600.

For golang/go#70914

Change-Id: I0efded4b1ac3e3c6b9479f18402e02e9e764d4a2
Reviewed-on: https://go-review.googlesource.com/c/net/+/744220
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-02-12 14:10:23 -08:00
Nicholas S. Husin
c1bbe1a459 internal/http3: add client to server trailer header support
This change adds support for ClientConn to send trailer headers, and for
Server to receive trailer headers. Support for the other direction will
be done in a follow-up change.

The encoding and decoding of trailer headers are done using bodyWriter
and bodyReader respectively, as these logic are agnostic to whether the
trailer header is sent by the client or the server.

For golang/go#70914

Change-Id: I646d193ae1bc44ddea69b8397d4473d3b11eddf2
Reviewed-on: https://go-review.googlesource.com/c/net/+/743600
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-02-12 14:10:11 -08:00
Dmitri Shuralyov
29181b8c03 all: remove go1.25 and older build constraints
Now that the x/net module requires Go 1.25.0,
the go1.25 build constraint is always satisfied.
Simplify the code accordingly.

Change-Id: I3d6fe4a132a26918455489b998730b494f5273c4
Reviewed-on: https://go-review.googlesource.com/c/net/+/744800
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-02-12 07:53:52 -08:00
Gopher Robot
81093053d1 all: upgrade go directive to at least 1.25.0 [generated]
By now Go 1.26.0 has been released, and Go 1.24 is no longer supported
per the Go Release Policy (see https://go.dev/doc/devel/release#policy).

See go.dev/doc/godebug#go-125 for GODEBUG changes relevant to Go 1.25.

For golang/go#69095.

[git-generate]
(cd . && go get go@1.25.0 && go mod tidy)

Change-Id: I15bcff18ee591756454a56b212d91aa0453e8e7c
Reviewed-on: https://go-review.googlesource.com/c/net/+/744580
Reviewed-by: Junyang Shao <shaojunyang@google.com>
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>
2026-02-11 11:12:51 -08:00
Damien Neil
0b37bdfdf0 quic: don't run TestStreamsCreateConcurrency in synctest bubble
This test creates a pair of real UDP sockets; synctest doesn't work
well with real network connections and interactions between the
real network and synctest are probably causing flakiness.

Fixes golang/go#76510

Change-Id: I9e8a959e7d0077d8191ceb8284f6c338dd2688ab
Reviewed-on: https://go-review.googlesource.com/c/net/+/743402
Auto-Submit: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-02-09 11:37:01 -08:00
Nicholas S. Husin
9095c1cb86 internal/http3: more robust handling of request & response with no body
In HTTP/3, zero or more DATA frames can come after a HEADERS frame to
represent a request or response body. Our current implementation can
behave rather badly when zero DATA frame is sent.

ClientConn does not close the write direction of the stream when it has
no body to send. As a result, our Server can end up reading the next
frame after a HEADERS frame, only to hang infinitely until the timeout
is reached. To fix this, when there is no body to send, ClientConn now
closes the write direction of the stream as soon as it has finished
writing its HEADERS frame. Server will also prevent itself from reading
the stream if a Content-Length header with the value 0 is received.

In the opposite direction (client reading response from a server), a
similar problem also exists, with a slight variant. While our Server
reliably closes its write direction of the stream as soon as the server
handler exits, a problem can still occur when a client receives an empty
response body due to sending a HEAD request. In this case, if the client
decides to read the response body, bodyReader might throw an error due
to a mismatch between the Content-Length header given by the server and
the actual body length. This is fixed by making ClientConn aware that
HEAD requests will always result in an empty response body.

For golang/go#70914

Change-Id: I1e8970672e7076c9dbf84aec8808632d04bac807
Reviewed-on: https://go-review.googlesource.com/c/net/+/742960
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-02-09 11:17:18 -08:00
Gopher Robot
ebddb99633 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I5e9ca4c38dd59f5c3332ee2e8bac98c338620b69
Reviewed-on: https://go-review.googlesource.com/c/net/+/743400
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.50.0
2026-02-09 09:11:27 -08:00
Nicholas S. Husin
4a490d4f53 internal/http3: add Expect: 100-continue support to ClientConn
When sending a request containing the "Expect: 100-continue" header,
ClientConn.RoundTrip will now only send the request body after receiving
an HTTP 100 status response from the server.

For golang/go#70914

Change-Id: Ib3acea68b078486bda96426952897c3f2d51b47b
Reviewed-on: https://go-review.googlesource.com/c/net/+/742540
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-02-06 16:20:02 -08:00
Nicholas S. Husin
73fe7011ad internal/http3: add Expect: 100-continue support to Server
When serving a request containing the "Expect: 100-continue" header,
Server will now send an HTTP 100 status automatically if the request
body is read from within the server handler.

For golang/go#70914

Change-Id: Ib8185170deabf777a02487a1ded6671db720df51
Reviewed-on: https://go-review.googlesource.com/c/net/+/742520
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-02-06 16:19:57 -08:00
Carlana
af0c9df79d html: add NodeType.String() method
Uses stringer to add String method to html.NodeType.

Fixes golang/go#77006

Change-Id: I8120215f859f4c3e6f17757e106cff3936bfa1ba
GitHub-Last-Rev: 2082ce04b3
GitHub-Pull-Request: golang/net#244
Reviewed-on: https://go-review.googlesource.com/c/net/+/738100
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2026-02-06 09:29:02 -08:00
Nicholas S. Husin
e02fb33933 internal/http3: make responseWriter.Flush write headers if not done yet
In net/http and x/net/http2, flushing an http.ResponseWriter will also
trigger headers to be written if none has been written yet at that
point. This behavior is sometimes relied on when implementing streaming
responses (see http://go.dev/cl/4552062); therefore, let's do this in
x/net/internal/http3 too.

For golang/go#70914

Change-Id: Ib914afc85df21a1cddd1d5019311d3f25d943f8a
Reviewed-on: https://go-review.googlesource.com/c/net/+/742160
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-02-05 18:42:21 -08:00
Nicholas S. Husin
da558ff100 internal/http3: ensure bodyReader cannot be read after being closed
Closing bodyReader currently only closes the underlying QUIC stream. As
a result, any unread data that was written to bodyStream prior to it
being closed can still be read. This is inconsistent with how we expect
net/http.Response.Body to behave.

For golang/go#70914

Change-Id: I58226c0d23ea3bbd97f3ceb5c3659e91660f84c5
Reviewed-on: https://go-review.googlesource.com/c/net/+/741982
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-02-05 18:42:11 -08:00
Nicholas S. Husin
d7c76faf07 internal/http3: make responseWriter behave closer to other http.ResponseWriter
While running net/http tests against our HTTP/3 implementation locally,
some tests fail due to slight behavior differences in responseWriter
compared to other http.ResponseWriter implementations:

- responseWriter does not return a 200 OK response if a server handler
  is completely empty.
- responseWriter does not have a Flush method, and therefore does not
  implement http.Flusher.

There are surely more differences, but these are straightforward to fix
right now.

For golang/go#70914

Change-Id: Ieb729a4de4ccb55d670eac2369e73c240b9ac8f8
Reviewed-on: https://go-review.googlesource.com/c/net/+/741720
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-02-03 11:53:50 -08:00
Nicholas S. Husin
64b3af9625 http2: prevent transport deadlock due to WINDOW_UPDATE that exceeds limit
Transport currently deadlocks when receiving a WINDOW_UPDATE for a
non-zero stream that increments its window beyond the 2^31-1 bytes
limit.

This is because endStreamError is called to end the non-zero stream,
which tries to lock an already-locked mutex. Therefore, create and use
endStreamErrorLocked instead, which assumes the mutex is already locked.

Fixes golang/go#77331

Change-Id: Iea212f49a1f305d1bddefb8831dbaca00840870c
Reviewed-on: https://go-review.googlesource.com/c/net/+/739700
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-02-02 09:54:04 -08:00
Nicholas S. Husin
1973e8da2d internal/http3: add Server support for handling HEAD requests
When handling HEAD requests, Server will now always send an HTTP
response with an empty body, even if the HTTP handler would normally
write to the body.

For golang/go#70914

Change-Id: Id656a8f9901b97357a343e204761f6a47f87f9fe
Reviewed-on: https://go-review.googlesource.com/c/net/+/740160
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-01-29 09:40:02 -08:00
Tobias Klauser
57ea86db08 icmp, internal/socket, ipv4, ipv6: use binary.NativeEndian
Instead of duplicating it as internal/socket.NativeEndian.

Change-Id: I7c7d76cc561b0f3083e8f33db7b90e2f421c12d5
Reviewed-on: https://go-review.googlesource.com/c/net/+/739840
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2026-01-29 07:04:13 -08:00
Neal Patel
bcf2273e01 quic: clean up impossible nil conditions
Change-Id: I755d937332f671a7f5bedc73aaff31e6fbf07159
Reviewed-on: https://go-review.googlesource.com/c/net/+/739760
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-27 14:57:05 -08:00
Nicholas S. Husin
6b849cc122 internal/http3: populate some http.Request fields
Currently, we are passing a very barebone http.Request to the server
handler: we only initialize an empty http.Request and put whatever info
we can get while decoding QPACK headers.

Unfortunately, this causes the Server to panic when parsing requests
whose headers are meant to be written to http.Request.URL, as
http.Request.URL was never initialized.

Therefore, make sure that http.Request.URL is initialized. Also,
populate other http.Request fields that we can easily figure out as of
now.

For golang/go#70914

Change-Id: Ie6552d6678b430fe4b51069616c0e366791c4e34
Reviewed-on: https://go-review.googlesource.com/c/net/+/738880
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-01-23 12:44:29 -08:00
Nicholas S. Husin
f2078620ee http2: allow prioritization to be disabled using DisableClientPriority field
As part of adding support for HTTP/2 stream prioritization, a
DisableClientPriority field will be added to http.Server to allow users
to completely disable client prioritization if desired. When
DisableClientPriority is set to true, HTTP/2 server will revert back to
the old behavior where streams are processed in a round-robin manner.

For golang/go#75500

Change-Id: Ida083b3ac17a953e5ddb3ad7ab8a81f9cde2bfc1
Reviewed-on: https://go-review.googlesource.com/c/net/+/737521
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-22 14:59:15 -08:00
Nicholas S. Husin
6640454869 internal/http3: break dependency on internal/quic/quicwire
internal/http3 currently depends on internal/quic/quicwire only for its
SizeVarint when writing SETTINGS frame. This makes bundling
internal/http3 into std more complicated since it forces us to also
bundle internal/quic/quicwire and do import remapping. This CL breaks
this dependency for easier bundling.

Dependency on internal/quic/quicwire in test codes have been left alone
since they do not affect bundling into std, and uses more than just
SizeVarint.

Change-Id: I2b85c5487ae6cce422deb4509f68f932d3f0de6b
Reviewed-on: https://go-review.googlesource.com/c/net/+/738060
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-01-21 14:58:16 -08:00
Nicholas S. Husin
c082574f2d internal/http3: remove GODEBUG=asynctimerchan=0 that is no longer needed
Change-Id: I86e83567b1d07fbc96ac98e0a85eb80748512eef
Reviewed-on: https://go-review.googlesource.com/c/net/+/737520
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-01-20 09:02:49 -08:00
Nicholas S. Husin
8f003b3712 http2: support SETTINGS_NO_RFC7540_PRIORITIES in SETTINGS frame
To make sure that clients do not unnecessarily send RFC 7540 priority
signals when it would be treated as a no-op, this change makes it so
that our server always sends SETTINGS_NO_RFC7540_PRIORITIES in our
SETTINGS frame when our write scheduler is set to anything other than
the RFC 7540 write scheduler.

For golang/go#75500

Change-Id: I7a54251022087319999deda7efb663f8b251aa95
Reviewed-on: https://go-review.googlesource.com/c/net/+/729141
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-01-14 12:33:57 -08:00
Nicholas S. Husin
8a4d9c198f http2: only make streams non-incremental if clients know of RFC 9218
In RFC 9218, streams are non-incremental by default, meaning that they
are processed one-by-one to completion. This behavior is the opposite of
our current default of handling streams in a round-robin manner.

This might cause a surprising behavior change once we make the RFC 9218
priority scheduler the default write scheduler for most users (we assume
that most users will not be sending RFC 9218 priority signals, at least
initially). To avoid surprising users with such a behavior change, this
CL makes it so that the streams are only made non-incremental once there
has been a clear signal that the end-user is aware of RFC 9218.

For golang/go#75500

Change-Id: Ibd22cb279c43de0190962904c3809007447a5fe3
Reviewed-on: https://go-review.googlesource.com/c/net/+/729140
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-01-14 12:33:43 -08:00
Nicholas S. Husin
a475fa8141 http2: add support for setting RFC 9218 priority via header field
RFC 9218 allows HTTP/2 stream priority to be set in two ways: via
PRIORITY_UPDATE frame and via header field. This change adds support for
the latter method.

As part of supporting priority adjustment via header field, this CL
also makes sure to look for the existence of an intermediary. If an
intermediary exists, default priority will be used for all streams to
ensure fairness between multiple clients who could be using the same
intermediary.

For golang/go#75500
For golang/go#75936

Change-Id: I6dc409b650fd52fa192d771a16b7a4ac5e51c9aa
Reviewed-on: https://go-review.googlesource.com/c/net/+/729120
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-01-14 12:33:32 -08:00
Nicholas S. Husin
f40205b5b5 http2: add initial support for PRIORITY_UPDATE frame defined in RFC 9218
This change adds initial support for the PRIORITY_UPDATE frame
introduced in RFC 9218.

Clients can now use a new exported function to write PRIORITY_UPDATE
frames easily. However, sending PRIORITY_UPDATE frames to the server
does not currently cause any behavior changes: we only use
PRIORITY_UPDATE frames to adjust stream priority when the RFC 9218 write
scheduler is being used for a particular connection. However, this
scheduler is not currently usable yet from any configuration surfaces
exposed to the user.

For golang/go#75500

Change-Id: Ie2c821cb0d2faa6e942e209e11638f190fc98e2b
Reviewed-on: https://go-review.googlesource.com/c/net/+/705917
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2026-01-14 12:33:16 -08:00
Nicholas S. Husin
15b99c1fb8 internal/http3: add basic request stream handling for the server
Add support for the server to handle basic request streams.
Specifically, reading HTTP headers & body in requests, and writing HTTP
headers & body in responses.

More sophisticated behaviors, such as dealing with 1xx status and
trailing headers, will be done in the future.

For golang/go#70914

Change-Id: I6a00435d72a118efe2ab76e4c7c53b9dca1d63f6
Reviewed-on: https://go-review.googlesource.com/c/net/+/735820
Reviewed-by: Nicholas Husin <husin@google.com>
Auto-Submit: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-13 07:38:07 -08:00
Gopher Robot
d977772e17 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I335bdc9150b51cb7d8ebd29721580dcdd5cb49ba
Reviewed-on: https://go-review.googlesource.com/c/net/+/735680
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: Cherry Mui <cherryyz@google.com>
v0.49.0
2026-01-12 08:15:11 -08:00
Nicholas S. Husin
eea413e294 internal/http3: use go1.25 synctest.Test instead of go1.24 synctest.Run
internal/http3 was written back in go1.24, and relies on synctest.Run
and goexperiment.synctest. This prevents us from running tests with
newer versions of Go.

This CL updates the existing build constraint and synctest usages to
go1.25 so we can still run tests using go1.25 and tip. Support for
running synctest with go1.24 is not kept, since go1.26 release (and
therefore x/net go.mod updating to go1.25) is expected soon.

Change-Id: Iebfa82ebd1da4a06ba613ce0f45051f4691037fc
Reviewed-on: https://go-review.googlesource.com/c/net/+/734940
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-09 07:13:59 -08:00
Nicholas S. Husin
9ace223794 websocket: add missing call to resp.Body.Close
Within hybiClientHandshake, after getting a response from
http.ReadResponse, the body is never closed.

When running a debugger with all of our test cases, this seems to not
matter usually since the body is typically a http.noBody, whose Close
just returns nil. However, this is not always the case. Therefore, this
CL adds the missing resp.Body.Close call.

Fixes golang/go#76952

Change-Id: I292d6ccc8eb101b806738aa7fc3e5446b623d861
Reviewed-on: https://go-review.googlesource.com/c/net/+/734240
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-01-06 15:45:35 -08:00
Nicholas S. Husin
7d3dbb06ce http2: buffer the most recently received PRIORITY_UPDATE frame
Per RFC 9218, servers should buffer the most recently received
PRIORITY_UPDATE frame. This CL implements said buffering within the RFC
9218 priority write scheduler.

For golang/go#75500

Change-Id: I259f4f6787053de6388ec513086cfa1b294fa607
Reviewed-on: https://go-review.googlesource.com/c/net/+/728401
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2025-12-08 15:11:37 -08:00
Gopher Robot
35e1306bdd go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I9679bad7bfc127003a80fc41dab3cf34aaff78be
Reviewed-on: https://go-review.googlesource.com/c/net/+/728182
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
v0.48.0
2025-12-08 13:41:29 -08:00
Dmitri Shuralyov
7c360367ab http2, webdav, websocket: fix %q verb uses with wrong type
Caught early by the improved vet check gated behind the 1.26 language
version combined with a tiplang builder that tests with 1.26 language
version.

Fixes golang/go#76574.
Fixes golang/go#76599.
Fixes golang/go#76547.

Change-Id: If8e2266013df0a39fc980a1e9287f8cb75949811
Cq-Include-Trybots: luci.golang.try:x_net-gotip-linux-amd64-tiplang
Reviewed-on: https://go-review.googlesource.com/c/net/+/725220
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Commit-Queue: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-11-28 14:06:04 -08:00
Marcus Efraimsson
ec11eccf5a trace: fix data race in RenderEvents
This commit updates the RenderEvents function by moving the read
lock for event families so that it happens before checking the
length of event families and by that fixing a data race problem.

Fixes golang/go#76402

Change-Id: Id02ebaa25cec8ef631aaf928ba084b0692e84583
Reviewed-on: https://go-review.googlesource.com/c/net/+/723160
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Sean Liao <sean@liao.dev>
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>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
2025-11-24 17:04:07 -08:00
Damien Neil
bff14c5256 http2: don't PING a responsive server when resetting a stream
When sending a RST_STREAM for a canceled request, we sometimes send
a PING frame along with the reset to confirm that the server is responsive
and has received the reset.

Sending too many PINGs trips denial-of-service detection on some servers,
causing them to close a connection with an ENHANCE_YOUR_CALM error.

Do not send a PING frame along with an RST_STREAM if the connection
has displayed signs of life since the canceled request began.
Specifically, if we've received any stream-related frames since the
request was sent, assume the server is responsive and do not send a PING.

We still send a PING if a request is canceled and no stream-related
frames have been received from the server since the request was first
sent.

For golang/go#76296

Change-Id: I1be3532febf9ac99d65e9cd35346c02306db5f9d
Reviewed-on: https://go-review.googlesource.com/c/net/+/720300
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-11-24 14:35:53 -08:00
Damien Neil
88a642172c dns/dnsmessage: avoid use of "strings" and "math" in dns/dnsmessage
dns/dnsmessage is used by the net package, which does not have
strings and math in its permitted dependencies.

Change-Id: I2b59887c59891dc61e49dd6430f3a72486ddd66a
Reviewed-on: https://go-review.googlesource.com/c/net/+/723902
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
2025-11-24 14:33:11 -08:00
Damien Neil
123d099e1b http2: support net/http.Transport.NewClientConn
Permit net/http to create new HTTP/2 client connections.

We do this by adding a NewClientConn method to the type the HTTP/2 client
registers with net/http.Transport.RegisterProtocol, which creates a
persistent connection from a net.Conn.

No tests in this CL. Tests will be in net/http, and will cover
both the HTTP/1 and HTTP/2 paths for NewClientConn.

For golang/go#75772

Change-Id: Ib1a06b4d13fdd6008e5db9a090c6e9632029a2a4
Reviewed-on: https://go-review.googlesource.com/c/net/+/722200
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2025-11-24 11:30:53 -08:00
Damien Neil
346cc6157e webdav: relax test to check for any redirect status, not just 301
CL 720820 changed net/http to use a 307 Temporary Redirect instead of
a 301 Moved Permanently when performing an automatic redirect under
some circumstances. Update tests in the webdav package to be agnostic
on the exact redirect status code.

Change-Id: I71784a738d18928a98387ddbd5475d50b19d15bf
Reviewed-on: https://go-review.googlesource.com/c/net/+/723120
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Nicholas Husin <nsh@golang.org>
2025-11-21 16:46:41 -08:00
Gopher Robot
9a296438e5 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: I166e970128861674939fc46eaad37f74d19f1745
Reviewed-on: https://go-review.googlesource.com/c/net/+/719680
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.47.0
2025-11-11 10:55:31 -08:00
Damien Neil
07cefd8a6b context: deprecate
Long superseded by the stdlib's context package.

Fixes golang/go#49506

Change-Id: I16e9a1275a7370cd78d11180f608ae28ecdce143
Reviewed-on: https://go-review.googlesource.com/c/net/+/719060
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-11-08 12:28:41 -08:00
Sean Liao
5ac9daca08 publicsuffix: don't treat ip addresses as domain names
While IP addresses are not domain names and probably
shouldn't be passed to these functions at all, it seems
wrong to have it handle IPv4 and IPv6 differently.

Fixes golang/go#32979

Change-Id: Id321a08b552c11d990c3966636b64793f762143f
Reviewed-on: https://go-review.googlesource.com/c/net/+/715100
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-11-04 13:39:14 -08:00
Damien Neil
d1f64cc670 quic: use testing/synctest
Replace bespoke fake time and synchronization with testing/synctest.

Change-Id: Ic3fe9635dbad36c890783c38e00708c6cb7a15f8
Reviewed-on: https://go-review.googlesource.com/c/net/+/714482
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-10-27 13:48:05 -07:00
Nicholas S. Husin
fff0469cf5 http2: document that RFC 7540 prioritization does not work with small payloads
This change demonstrates that golang/go#75936 applies to the RFC 7540
write scheduler.

A similar test will be added for RFC 9218 write scheduler after support
for it is incorporated within http2/server.go.

For golang/go#75936

Change-Id: I4e05dbeb0aab71942eb699b67383ef5b52c3ef4d
Reviewed-on: https://go-review.googlesource.com/c/net/+/714741
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2025-10-24 15:04:41 -07:00
Nicholas S. Husin
f35e3a4dd2 http2: fix weight overflow in RFC 7540 write scheduler
We use uint8 (0-255, inclusive) to represent the RFC 7540 priorities
weight (1-256, inclusive). To account for the difference, we add 1 to
the uint8 weight value within sortPriorityNodeSiblingsRFC7540.

However, the addition was done before converting the uint8 type to
float. As a result, when provided a maximum weight value, overflow will
happen and will cause the scheduler to treat the maximum weight as a
minimum weight instead.

This CL fixes the issue by making sure the addition happens after the
type conversion.

Change-Id: I404e87e5ad85fa06d5fa49cda613c93ac8847bdc
Reviewed-on: https://go-review.googlesource.com/c/net/+/714742
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2025-10-24 15:04:30 -07:00
Nicholas S. Husin
89adc90ac4 http2: fix typo referring to RFC 9218 as RFC 9128 instead
In go.dev/cl/704758, I accidentally typed RFC 9128 rather than 9218.
This changes fixes all such typo.

For go/golang#75500

Change-Id: I61c3008a85ca0ca0e9f58315cb5eb20cd82fb9f9
Reviewed-on: https://go-review.googlesource.com/c/net/+/714740
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-24 15:04:23 -07:00
Damien Neil
8d76a2c082 quic: don't defer MAX_STREAMS frames indefinitely
Avoid a state where we can have a MAX_STREAMS frame to send,
but do not send the frame for an indefinite amount of time.

Conn.appendStreamFrames writes stream-related frames to
the current packet. It also handles removing streams
from the Conn when we no longer need to track their state.

Removing streams can affect the frames we want to send.
In particular, we may want to send a MAX_STREAMS to the
peer indicating that it can open more streams because
we've closed out some of the existing ones.

Add MAX_STREAMS after removing streams, to ensure we
pick up any changes to the sent value before adding it.

This case doesn't show up in  tests, because the test harness's
idleness detection causes the Conn's event loop to run and notice
the pending MAX_STREAMS frame. Changing tests to use
testing/synctest (a followup CL) causes the problem to
appear, because the event loop isn't run while the Conn
is idle.

Change-Id: Ia7394891317dae6ecfd529a9b3501ac082cb453e
Reviewed-on: https://go-review.googlesource.com/c/net/+/714481
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2025-10-24 07:51:19 -07:00
Damien Neil
027f8b700e quic: fix expected ACK Delay in client's ACK after HANDSHAKE_DONE
testConn.handshake runs through the initial QUIC handshake
and verifies that the connection under test sends an expected
sequence of handshake messages.

The last datagram in the handshake is sent by the client,
and contains an ACK for the last datagram sent by the server.

The client sends this ACK after max_ack_delay (25ms) passes, minus
the timer granularity (1ms). The timer granularity is a constant
containing the expected maximum delay between a timer event's
scheduled time and the timer actually firing.

The expected handshake datagram used by testConn.handshake contains
an ACK with an ACK Delay value of 25ms (max_ack_delay).
This doesn't account for the timer granularity adjustment.
However, since testConn.handshake advances time by 25ms rather than 24ms,
the test connection sends the ACK at the later time and includes a
larger ACK Delay value.

Fix testConn.handshake to sleep for the expected delay (24ms).
Fix the expected handshake datagram accordingly.

This all avoids test failures after switching this package to use
testing/synctest's fake clock, under which the connection sends
this ACK at the scheduled time rather than a time under direct
control of the test.

Change-Id: I1af6e02e02f6493758e41db45a46d06a65441a7b
Reviewed-on: https://go-review.googlesource.com/c/net/+/714480
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2025-10-24 07:51:16 -07:00
Vinicius Fortuna
dec9fe711e dns/dnsmessage: update SVCB packing to prohibit name compression
This commit updates the dns/dnsmessage package to correctly handle SVCB record
packing by prohibiting name compression for the Target field.

It turns out the compression of names in RDATA is prohibited (see
https://datatracker.ietf.org/doc/html/rfc3597#section-4), except for well-known record
types (those defined in https://datatracker.ietf.org/doc/html/rfc1035).

The SVCB RFC actually explicitly calls that out
(https://datatracker.ietf.org/doc/html/rfc9460#section-2.2), so it was an oversight
in my part in https://go.dev/cl/710736.

Updates golang/go#43790

Change-Id: I287b034c9e01b49264e07e23293bacd830ab1832
GitHub-Last-Rev: 1d16664c57
GitHub-Pull-Request: golang/net#242
Reviewed-on: https://go-review.googlesource.com/c/net/+/713900
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Vinicius Fortuna <fortuna@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-10-23 13:39:34 -07:00
cuishuang
9be1ff2808 all: fix some comments
Change-Id: I4a06e68307ac3deb5b2e1bab9235ebe01dcd4ea6
Reviewed-on: https://go-review.googlesource.com/c/net/+/713380
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
2025-10-23 07:34:54 -07:00