2324 Commits

Author SHA1 Message Date
Nicholas S. Husin
44c41bee50 internal/http3: prevent server from holding mutex when sleeping during shutdown
If the server holds the lock while sleeping when shutting down,
connections will not be able to unregister themselves from s.activeConns
after receiving the GOAWAY frame from the server. This will then cause
the server to abort connections unnecessarily after it is done sleeping.

Change-Id: I2bce91785db2d138f7bea3a26311139c6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/760560
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-03-27 14:17:38 -07:00
Nicholas S. Husin
228a67a374 internal/http3: add CloseIdleConnections support in transport
Currently, our HTTP/3 transport creates a QUIC endpoint that is never
closed when dialing a connection for the first time.

To prevent lingering resource that is never cleaned up until a program
exits, we now close the QUIC endpoint when CloseIdleConnections is
called and no connections need the endpoint anymore.

For golang/go#70914
For golang/go#77440

Change-Id: I0e4cb131c161216dd8e6abacfc4e57e79be63d7c
Reviewed-on: https://go-review.googlesource.com/c/net/+/754741
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-03-27 14:10:48 -07:00
Nicholas S. Husin
7b75446a98 internal/http3: add shutdown support for server
Currently, our HTTP/3 server that has been registered against a net/http
Server will keep running even after the net/http Server has shutdown.

Therefore, add support for shutting down a running HTTP/3 server, and
use it as part of net/http.Server.RegisterOnShutdown.

For golang/go#70914
For golang/go#77440

Change-Id: I5d2acd2cb0fef64ecf5f8d81ae79f3399ed97b00
Reviewed-on: https://go-review.googlesource.com/c/net/+/754580
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-03-26 17:43:53 -07:00
Nicholas S. Husin
c48da250e2 internal/http3: panic in server handler if given status that is not 3 digits
Our HTTP/1 and HTTP/2 server implementations will panic when WriteHeader
is called from a handler with a status code that is not 3 digits. For
consistency, do this too for HTTP/3.

For golang/go#70914

Change-Id: I65aca23ea186481ae06c7388db487e476a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/759300
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-03-25 14:16:51 -07:00
Nicholas S. Husin
a4b5ad55af internal/http3: streamline synctest.Wait usage in tests
Change-Id: I40e5e2d033e9f1c51b419de1347295073b99de9a
Reviewed-on: https://go-review.googlesource.com/c/net/+/758824
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-03-24 17:51:37 -07:00
Olivier Mengué
70576f07de http/httpproxy: godoc fixes
Doc improvements:
- use godoc link to net/http
- link use go.dev instead of golang.org
- fix typo in ProxyFunc doc

Change-Id: I7be0ebc78b3c34bc50fac6edc2c20a713478a315
Reviewed-on: https://go-review.googlesource.com/c/net/+/757980
Auto-Submit: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-24 07:44:58 -07:00
Nicholas S. Husin
157f4d57d9 quic: prevent server panic when handling Retry packets with short connection ID
Per RFC 9000, a Destination Connection ID in a Retry packet is of valid
length as long as it is 20 bytes or shorter. However, when validating
tokens for Retry packets, our server currently makes an assumption that
it will only deal with a Destination Connection ID that is exactly 20
bytes long. As a result, a misbehaving or malicious client can cause our
server to panic.

When our server validates a token for a Retry packet, the nonce is
partially constructed from the Destination Connection ID. Due to our
server's bad assumption, a shorter-than-expected Destination Connection
ID will result in cipher.AEAD.Open being given a nonce of bad length. We
currently use XChaCha20-Poly1305 from x/crypto for our AEAD
implementation, which will panic when given a nonce of bad length.

Fixes golang/go#78292

Change-Id: Ieb65d8b84bcb5c531bdb46d5c75b13dad9c76eb2
Reviewed-on: https://go-review.googlesource.com/c/net/+/758360
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-03-23 13:38:59 -07:00
Damien Neil
faf99b58f2 quic: document that this is not yet covered by the security policy
Implied by "work in progress", but let's be explicit about it.

Change-Id: I5cc39129e5af8effb4cc64b0b07ff2176a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/758240
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
2026-03-23 11:07:07 -07:00
Nicholas S. Husin
af27605f51 quic: avoid usage of net.ReadMsgUDPAddrPort in non-linux and darwin builds
Amongst the non-linux and darwin builds, net.ReadMsgUDPAddrPort is not
implemented yet in plan9. There does not seem to be any reason why we
could not use net.ReadFromUDPAddrPort instead, which is implemented in
plan9.

Therefore, use net.ReadFromUDPAddrPort instead for better compatibility.

Fixes golang/go#78223

Change-Id: Id397f28368f0cc291b12c6e06df3de64321a623b
Reviewed-on: https://go-review.googlesource.com/c/net/+/757100
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Auto-Submit: Nicholas Husin <nsh@golang.org>
Reviewed-by: Ethan Lee <ethanalee@google.com>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
2026-03-19 19:36:52 -07:00
Nicholas S. Husin
2a1610a029 internal/http3: skip TestNetHTTPIntegration on plan9
TestNetHTTPIntegration relies on ReadMsgUDP which is currently
unimplemented in plan9.

For golang/go#78223

Change-Id: I958f5f1324236e540a9c8cdf4f2b3c805f023732
Reviewed-on: https://go-review.googlesource.com/c/net/+/757000
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Ethan Lee <ethanalee@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-19 11:46:05 -07:00
Nicholas S. Husin
6d6c88c894 internal/http3: prevent panic in TestNetHTTPIntegration
t.Errorf was accidentally used instead of t.Fatal for an error that we
cannot tolerate.

For golang/go#78223

Change-Id: Ice6b566359f8d138627f7a3509b625741b9bd5cf
Reviewed-on: https://go-review.googlesource.com/c/net/+/756920
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ethan Lee <ethanalee@google.com>
Reviewed-by: Richard Miller <millerresearch@gmail.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-19 10:22:40 -07:00
Damien Neil
10ac4db832 http2: deflake TestServer_Rejects_Too_Many_Streams
This CL is the x/net counterpart to CL 755320.

This test contains a race condition in the server handler:

	inHandler <- streamID
	<-leaveHandler

We assume that all requests queue reading from leaveHandler in order,
but it is possible for the second request (stream id 3) to arrive at
leaveHandler before the first (stream id 1).

We could fix the race with a judicious synctest.Wait, but rewrite
the test to use serverHandlerCall to manipulate server handlers,
which permits us to precisely pick which request to unblock.

Fixes #69670

Change-Id: I9507d1dba07f7d62bcdc6c9bb67c47466a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/755081
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-16 10:43:20 -07:00
Nicholas S. Husin
af2121a04e internal/http3: avoid blocking when closing a server's QUIC endpoint
Several tests such as TestServerReceivePushStream are currently flaky.
This is because the synctest test finishes before the test server
finishes closing its QUIC endpoint.

To prevent this flakiness, make sure that the server uses a canceled
context when closing the QUIC endpoint, so as to not block.

Fixes golang/go#78100
Fixes golang/go#78101
Fixes golang/go#78102

Change-Id: I88a257d68dfbcf4e1f18b600a2f11dfdabecb078
Reviewed-on: https://go-review.googlesource.com/c/net/+/754740
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-03-12 10:37:40 -07:00
Gopher Robot
316e20ce34 go.mod: update golang.org/x dependencies
Update golang.org/x dependencies to their latest tagged versions.

Change-Id: Ie4bfdbe9480a9bcd1384b4f8060239cc7cfc6dee
Reviewed-on: https://go-review.googlesource.com/c/net/+/754560
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.52.0
2026-03-11 17:35:42 -07:00
Nicholas S. Husin
9767a42264 internal/http3: add support for plugging into net/http
This CL adds RegisterServer and RegisterTransport, which are used to
plug our HTTP/3 implementation into net/http. For now, (inaccurately)
assume that RegisterTransport do not take any configs for simplicity.

Various exported symbols have also been changed to be unexported, since
HTTP/3 will be used only via net/http and will not support direct usage.

For golang/go#77440

Change-Id: I7b9528c193c18f5049da7f497d4259153b8770eb
Reviewed-on: https://go-review.googlesource.com/c/net/+/739881
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-03-11 15:40:04 -07:00
Damien Neil
4a812844d8 http2: update docs to disrecommend this package
Every supported feature of the HTTP/2 client and server
is accessible via the net/http package. Recommend that
users use net/http rather than importing this package.

For #67810

Change-Id: I58b9c65af27e2f7172af493f96ee589a6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/752160
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>
Auto-Submit: Damien Neil <dneil@google.com>
2026-03-09 08:35:37 -07:00
Steven Richards
dec6603c16 dns/dnsmessage: reject too large of names early during unpack
The existing implementation of the Name.unpack method does not check the
length of the domain name until parsing is complete. This allows a
malicious user to supply an unreasonably large name and wastle cycles
parsing. This change moves an equivalent check into the loop during
process to short-circuit if we've created too large of a name.

For golang/go#77540

Change-Id: I4c4bf20c0342825a09cefd9b0b3c0bdce0c80137
Reviewed-on: https://go-review.googlesource.com/c/net/+/750260
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-03-06 10:52:24 -08:00
Damien Neil
8afa12f927 http2: deprecate write schedulers
The user-provided write scheduler mechanism provides too
much visibility into implementation internals, is difficult
to use, and limits our ability to improve performance.

Fixes golang/go#67817

Change-Id: Iac02c0902f805b671b4541a5dd7eafe76a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/751640
Auto-Submit: 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>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-05 16:11:29 -08:00
Damien Neil
38019a2dbc http2: add missing copyright header to export_test.go
Change-Id: I7add2f2ef54ef6f985154a60399768e76a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/751620
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>
Auto-Submit: Damien Neil <dneil@google.com>
2026-03-04 14:19:29 -08:00
Nicholas S. Husin
039b87fac4 internal/http3: return error when Write is used after status 304 is set
In our HTTP/1 and HTTP/2 implementations, calling Write in a server
handler after WriteHeader has been called with status 304 will return an
http.ErrBodyNotAllowed error. This change adds the same behavior for the
HTTP/3 server.

For golang/go#70914

Change-Id: I6be926412d51217a8b88b2ad4ce79935dd3e7af7
Reviewed-on: https://go-review.googlesource.com/c/net/+/751140
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-03-04 06:38:46 -08:00
Nicholas S. Husin
6267c6c4c8 internal/http3: add HTTP 103 Early Hints support to ClientConn
RoundTrip will now call httptrace.ClientTrace.Got1xxResponse, if any,
when receiving 1xx status response from a peer. This allows our client
and server to use HTTP 103 end-to-end.

Got100Continue and Wait100Continue have also been added to RoundTrip as
they are nearby. The rest of httptrace.ClientTrace will be added in the
future.

For golang/go#70914

Change-Id: Ia7ef7dd026a5390225149da3d76b06a2a372c009
Reviewed-on: https://go-review.googlesource.com/c/net/+/749265
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-03-04 06:38:43 -08:00
Nicholas S. Husin
591bdf35bc internal/http3: add HTTP 103 Early Hints support to Server
Using WriteHeader from Server handler to send status 103 will now work
similarly to HTTP/1 and HTTP/2. Additionally, the code path for handling
informational response header in general has also been simplified.

Support for the client is added in a separate change.

For golang/go#70914

Change-Id: I07bd15fc56d0b1e18f1831c9002d548dbfb5beb5
Reviewed-on: https://go-review.googlesource.com/c/net/+/749264
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-03-04 06:38:40 -08:00
Nicholas S. Husin
1faa6d8722 internal/http3: avoid potential race when aborting RoundTrip
TestRoundTripRequestBodyErrors/read_error currently has a small chance
of failing due to a race condition.

Most of the time, within writeBodyAndTrailer which runs concurrently,
when a request body returns an error on Read, rt.abort will be called
with the Read error. Since rt.abort is idempotent, the Read error will
then be propagated and the test would pass as expected.

However, before rt.abort is called with the Read error,
rt.reqBodyWriter.Close is first called, which will close the write
direction of the QUIC stream. This creates a small chance where the main
goroutine which runs RoundTrip can encounter an EOF error due to the
closed stream, and subsequently call rt.abort with a different error
than expected, causing test flakiness.

To fix this, this change makes sure that rt.abort is immediately called
when a request body Read returns an error. This should be a no-op, since
a body Read error has always been prioritized over a potential error
from rt.reqBodyWriter.Close anyways.

Fixes golang/go#77782

Change-Id: I9ec5acf82dd95ac91963ce5c8ddbf08b49af9508
Reviewed-on: https://go-review.googlesource.com/c/net/+/751280
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-03-04 06:38:26 -08:00
Damien Neil
8d297f1cac http2: Move most tests from the http2 package to the http2_test package.
This change makes it easier to move x/net/http2 into std.
Moving the http2 package into std and importing it from net/http
(rather than bundling it as net/http/h2_bundle.go) requires
removing the http2->net/http dependency. Moving tests into
the http2_test package allows them to continue importing net/http
without creating a cycle.

Change-Id: If0799a94a6d2c90f02d7f391e352e14e6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/net/+/749280
Auto-Submit: 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>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-03 17:16:54 -08:00
Nicholas S. Husin
3eb9327ec1 http2: do not retry RoundTrip after peer sends a stream protocol error
Years back, our HTTP/2 server implementation had a stream accounting bug
that would cause it to improperly report a PROTOCOL_ERROR. In response
to this, we modified our Transport to retry RoundTrip when a RST_STREAM
with PROTOCOL_ERROR was received from a peer.

At this point, this retry logic had outlived its usefulness. Instead, it
might cause issues, e.g. a client that sends a malformed request will
keep retrying repeatedly, despite there being zero chance for the
request to actually succeed.

Fixes golang/go#77843

Change-Id: Ic043723e3535f68f91db33d8f6bcd7fc2dbce856
Reviewed-on: https://go-review.googlesource.com/c/net/+/750720
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-03-02 15:02:12 -08:00
Nicholas S. Husin
60b3f6f8ce internal/http3: prevent Server handler from writing longer body than declared
Like in HTTP/1 and HTTP/2, this CL changes the Server handler so that
Write will return an error and automatically trim the content being
written, when attempting to write a body content that is longer than
what has been declared in the "Content-Length" header.

For golang/go#70914

Change-Id: I638efb8ec96f926f86c389f3cac79f1b38a5b36b
Reviewed-on: https://go-review.googlesource.com/c/net/+/748681
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>
v0.51.0
2026-02-24 16:19:02 -08:00
Nicholas S. Husin
b0ca456175 internal/http3: fix Write in Server Handler returning the wrong value
When changing the approach used in go.dev/cl/746760 (i.e. adjusting
slices, rather than keeping track of active part of the slices in
Write), the return value was unfortunately not updated properly.

This CL fixes the problem and modifies the test to also verify that
Write returns the correct value.

For golang/go#70914

Change-Id: Ic7dda43d47a85c74c03cf02208a0cd461b58dcf2
Reviewed-on: https://go-review.googlesource.com/c/net/+/748680
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-24 16:18:58 -08:00
Sean Liao
1558ba7806 publicsuffix: update to 2026-02-06
Test cases for wildcards (*) dropped as the
following registrations changed.

.uberspace.de removal
https://github.com/publicsuffix/list/pull/2540

.bd registration update to replace *.bd
https://github.com/publicsuffix/list/pull/2623

Fixes golang/go#77445

Change-Id: Ib3e120e041bcefce4d89b7f8fd4eb5ab752610c5
Reviewed-on: https://go-review.googlesource.com/c/net/+/742285
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-24 09:08:04 -08:00
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