aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
AgeCommit message (Collapse)Author
17 hoursall: prealloc slice with possible minimum capabilitiesShulhan
30 hoursnet/http: temporarily disable HTTP/3 testsNicholas S. Husin
Tests for HTTP/3 are unfortunately still flaky. The flakes seem to come mostly from two sources: 1. QUIC connections are not shutdown fast enough, causing them to be detected as goroutine leaks. 2. x/net/quic has a race condition where its output buffer are written to without locks (synchronously and intentionally, for optimization), but may be asynchronously written when the QUIC stream receives a STOP_SENDING frame. Therefore, skip http3Mode for now until the above flakes are fixed. For #70914 Fixes #78701 Change-Id: If0c857c0933b977fb10a4481124680726a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/766740 Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Nicholas Husin <husin@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
36 hoursnet/http: fix wrong context being used when shutting down HTTP/3 serverNicholas S. Husin
t.Context was accidentally used within a t.Cleanup. This is a mistake since t.Context will always have been cancelled by the time t.Cleanup runs. This is likely the reason for flakiness in some builders: our HTTP/3 finishes before QUIC connections can finish closing asynchronously, which are then detected as goroutine leaks. To account for this, also make the shutdown context timeout more generous. For #70914 Change-Id: I0e5f06a47ef25c5df535543fc1e602f16a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/766620 LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Damien Neil <dneil@google.com>
4 daysnet/http: run tests for HTTP/3 where it can already passNicholas S. Husin
By default, our test harnesses (run and runSynctest) now use http3Mode, in addition to http1Mode and http2Mode, when no []testMode were explicitly defined for a given test. Tests that cannot currently pass for HTTP/3 have been modified to use http3SkippedMode, which serves as a convenient alias for the old default of []testMode{http1Mode, http2Mode}. We changed the default mode and defined http3SkippedMode so we have a clear list of TODOs in terms of how much changes are still needed before our HTTP/3 implementation reaches basic feature parity with HTTP/1 and HTTP/2. For #70914 Change-Id: I719d5d66399a51f7c3d96180ebed9b606a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/765320 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>
4 daysnet/http: fix data race in TestClientRedirectUseResponseNicholas S. Husin
There is a data race between the assignment of ts, and the access of ts.URL in the server handler. The data race seems to be more common when running the test against our HTTP/3 implementation. Fix the issue by deriving ts.URL via the given Request in the server handler. For #70914 Change-Id: Ic1924bf2c814517bae6b2e999d5f7efa6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/765443 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>
5 daysnet/http: add support for running HTTP tests against HTTP/3Nicholas S. Husin
Add support within clientserver_test.go to bring up a test HTTP/3 server and client when http3Mode testMode option is passed. To be able to reuse net/http/httptest, net/http/httptest.Server.StartTLS (and Start) have been modified so they can be called with a nil Listener. In such cases, both methods will behave identically as usual, but will not actually make its server serve or set its transport dialer, both of which requires having a listener. This should be a no-op for regular users of the package, whose entrypoint via functions such as NewServer will automatically set a local listener. Actually enabling HTTP/3 for our tests will be done in a separate CL. For #70914 Change-Id: Ibc5fc83287b6a04b46e668a54924761a92b620a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/740122 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>
6 daysnet/http/internal/http2: prevent alloc when writing status code for responsesNicholas S. Husin
Previously, writing responses with non-200 and non-404 status code requires an allocation. Now that CL 762040 prevents header names and values from escaping, we can modify writeFrame to not allocate status codes on the heap. Change-Id: I230bed1b83627c1fb389c0507106d8e16a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/762140 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>
9 daysnet/http: fix shadow var frameWeixie Cui
Change-Id: Ib03f65992b065e169fa6ccd08664336bec559c1d GitHub-Last-Rev: bd597d4325c713c53a9f22cb93892d90f393c6ac GitHub-Pull-Request: golang/go#78527 Reviewed-on: https://go-review.googlesource.com/c/go/+/762700 Reviewed-by: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-31net/http/internal/http2: prevent hanging Transport due to bad SETTINGS frameNicholas S. Husin
When processing SETTINGS frame, Transport currently only checks if the frame is valid for SETTINGS_ENABLE_CONNECT_PROTOCOL. As a result, a SETTINGS_MAX_FRAME_SIZE with the invalid value of 0 is erroneously accepted. This will then result in Transport being stuck in an infinite loop writing CONTINUATION frames. This CL fixes the issue by ensuring that SETTINGS frame are always validated, regardless of the SETTINGS parameter. Thanks to Marwan Atia (marwansamir688@gmail.com) for reporting this issue. Fixes #78476 Fixes CVE-2026-33814 Change-Id: I8b6219431e87454d34bca738fbcb59b66a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/761581 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-31net/http: support passing Server Shutdown context to HTTP/3 implementationsNicholas S. Husin
Currently, when Server.Shutdown is called with a given context, an HTTP/3 server implementation does not have access to said context. This forces HTTP/3 server implementations to guess a reasonable fixed timeout when attempting to gracefully shutdown, which is not ideal. Therefore, add ShutdownContext method to http3ServerHandler to handle this. For #77440 Change-Id: Ib15b615f646fd08788981eb06f3a70606a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/761480 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-30net/http/internal/http2: don't reuse ClientRequest streamsDamien Neil
The ClientRequest type (unlike http.Request) is not reusable across RoundTrip attempts because it includes a single-use clientStream. (It's possible for RoundTrip to return while some goroutines are still accessing the clientStream.) Always clone the ClientRequest on retries. Fixes #78202 Fixes #78187 Change-Id: I4012bb4e017a9516278c873ec5a589086a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/761301 Reviewed-by: Nicholas Husin <husin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-24net/http/internal/http2: use fake net for TestTransportBlockingRequestWriteDamien Neil
This test has been intermittently flaky. Exact cause isn't clear, but switch it to use a fake network to eliminate local network flakiness as a cause. Fixes #78209 Fixes #78213 Fixes #78263 Change-Id: I481553107e8557fda0707069856bafcc6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/758063 Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-24net/http: add a test for starting a server with no HTTP/2 and no TLS configDamien Neil
Test for the fix in CL 758560. Change-Id: I34edf9f14dc5d6a569f20aa3d55d9d136a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/758661 Auto-Submit: Damien Neil <dneil@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-03-24net/http: fix panic in ServeTLS on nil TLSConfigchressie
Change-Id: I9bc588128ec36bb3725d15e52400b76a94e5cb3a Reviewed-on: https://go-review.googlesource.com/c/go/+/758560 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>
2026-03-23net/http/internal/http2: remove inaccessible write schedulersNicholas S. Husin
RFC 7540 and random write schedulers are not accessible from std, and are essentially dead code at this point. Change-Id: Ib1e9e6e9ae7962b451bc36c0dad3c503f56dc1c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/757380 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-23net/http: make ResponseWriter.ReadFrom respect declared Content-LengthNicholas S. Husin
Unlike ResponseWriter.Write, ResponseWriter.ReadFrom does not currently respect declared Content-Length header. As a result, it is possible for a server handler to inadvertently write more bytes for their response body than has been declared via Content-Length. These excess bytes are written to the wire, and could potentially be misinterpreted by a client as a separate response. That said, this is not a concern security-wise. This edge case can only be exercised by someone who has a relatively complete control of a server handler—by which point, worse things can be done with less effort. Regardless, this is still a bug. Therefore, make sure that ResponseWriter.ReadFrom respects declared Content-Length too for consistency. Fixes #78179 Change-Id: I469b064e43e49e467b907d23fc1ee879066569f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/755701 Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Nicholas Husin <nsh@golang.org> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-23net/http/internal/http2: modernize the packageqiulaidongfeng
This CL is mostly generated by running go fix. Manual edits have also been selectively done to modernize the package where doing so is straightforward; for example, using slices.Contains in lieu of strSliceContains. Change-Id: Ie2942481672c56c370e2df0f172cf3e480a12bc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/757220 Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-16net/http/internal/http2: deflake TestServer_Rejects_Too_Many_StreamsDamien Neil
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 #78117 Change-Id: Icd393c81e019a0b5176976a6b50145a26a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/755320 Reviewed-by: Nicholas Husin <nsh@golang.org> Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Nicholas Husin <husin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-12net/http/internal/http2: drop benchmarks which use synctestDamien Neil
Drop a number of low-level benchmarks which use internal test APIs that now use synctest. Synctest and benchmarks don't really mix; we don't necessarily expect bubbled code to perform in the same fashion as unbubbled code. Fixes #78114 Change-Id: I23f0a5d296ffeabc836f3865e08778eb6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/754940 Reviewed-by: Nicholas Husin <nsh@golang.org> Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-12net/http: use net/http/internal/http2 rather than h2_bundle.goDamien Neil
Rework net/http/internal/http2 to use internally-defined types rather than net/http types (to avoid an import cycle). Remove h2_bundle.go, and replace it with calls into net/http/internal/http2 instead. For #67810 Change-Id: I56a1b28dbd0e302ab15a30f819dd46256a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751304 Reviewed-by: Nicholas Husin <nsh@golang.org> 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>
2026-03-12net/http/internal/http2: skip TestTransportNewClientConnCloseOnWriteErrorDamien Neil
Rewrote this test to use newTestClientConn, discovered that the assertion that it's supposed to make (if a write to a conn fails, the conn is closed) doesn't hold for all writes. Skip the amended test for now. For #67810 Change-Id: I1b696afcd2ba86ed631ee5f32c48b2366a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/753842 Reviewed-by: Mark Freeman <markfreeman@google.com> Auto-Submit: Damien Neil <dneil@google.com> 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>
2026-03-12net/http/internal/http2: remove fake connection autowaitDamien Neil
Fake connections have an option to "autowait", where the connection calls synctest.Wait before a read or after a write. This causes some confusing problems in cases when a connection might be used elsewhere than the main test goroutine, possibly resulting in two synctest.Wait calls at the same time. Drop the autowait feature, and add some more explicit Waits as required. For #67810 Change-Id: I3ba96b2af3b3a2f171c44bfe47be1d7f6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/753841 Auto-Submit: Damien Neil <dneil@google.com> 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>
2026-03-12net/http/internal/http2: make server write errors stickyDamien Neil
After encountering a write error on a server's connection, remember the error and reuse it for future writes. Fixes a rare flakiness in TestServerWriteByteTimeout, where we can sometimes attempt to flush the write buffer after encountering a write timeout. Change-Id: I01649ae41185d6109180e222d4e8f8426a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/753720 Auto-Submit: Damien Neil <dneil@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-03-12net/http/internal/http2: remove ServeConnOpts.UpgradeRequestDamien Neil
UpgradeRequest is used by the x/net/http2/h2c package for upgrading HTTP/1.1 requests to unencrypted HTTP/2. net/http only supports unencrypted HTTP/2 "with prior knowledge", not upgrade. Drop the field. For #67810 Change-Id: Iae48386e2e299dbf3b433954b87b6eb86a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/753320 Reviewed-by: Nicholas Husin <nsh@golang.org> 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>
2026-03-12net/http: move DetectContentType into net/http/internalDamien Neil
The http2 package needs access to DetectContentType, so move it into a common location. For #67810 Change-Id: Ibff3d57a4931106c2f69c5717c06bd5f6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751701 Reviewed-by: Nicholas Husin <nsh@golang.org> 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>
2026-03-12net/http/internal/http2: remove TestClientConnPingDamien Neil
Ping is no longer a public API. For #67810 Change-Id: I7df19d443634ada23cf4137b96cb25676a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751311 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-12net/http/internal/http2: remove TestConfigureTransportDamien Neil
ConfigureTransport is no longer a public API. For #67810 Change-Id: I8dae19bc0635c77bafa202841ef468356a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751310 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> Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-12net/http/internal/http2: remove TestTransportGroupsPendingDialsDamien Neil
This test exercises dials in the client connection pool inside http2.Transport, but in the merged-into-std world dials are always handled by the net/http.Transport. For #67810 Change-Id: Ic047ec3628c48116f1eda3c145bf5a566a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751309 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>
2026-03-12net/http/internal/http2: remove TestServerUpgradeRequestPrefaceFailureDamien Neil
This test exercises the h2c upgrade path, where a client sends an HTTP/1 requests and receives an HTTP/2 response. We don't support this path any more, so drop the test. For #67810 Change-Id: Ib100c3afb18a98f613c19023cb2d5a026a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751308 Reviewed-by: Nicholas Husin <nsh@golang.org> 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>
2026-03-12net/http/internal/http2: remove TestServerHandleCustomConnDamien Neil
This test exercises the ability to provide a non-*tls.Conn to the HTTP/2 server. This is not currently supported by net/http.Server (although it would be nice to have), so drop the test. For #67810 Change-Id: Ica5b0bcceddbb75dcc2b4d5f69fad8676a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751307 Reviewed-by: Nicholas Husin <nsh@golang.org> 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>
2026-03-12net/http/internal/http2: use newServerTester in TestIssue53Damien Neil
Replace older test infrastructure with the new shiny. Simplifies keeping this test post merge into std. For #67810 Change-Id: Idd876af67265ae8b6ab5b82f9ac376d26a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751306 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-12net/http/internal/http2: remove TestServeConnNilOptsDamien Neil
ServeConn is no longer a public API, so there is no need to test this path. For #67810 Change-Id: I2f740ebf95777d5d44ea26f27aa812f46a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751305 Reviewed-by: Nicholas Husin <nsh@golang.org> Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-12net/http/internal/http2: remove ExportSetH2GoawayTimeoutDamien Neil
This was used by one test. Rewrite that test to use synctest (faster!) and not care about the timeout. For #67810 Change-Id: I61496e575ae8a16ff778470f3f9d711e6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751303 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> Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-12net/http/internal/http2: use net/http Transport and Server in testsDamien Neil
Update http2 tests to use a net/http Transport or Server where possible, rather than the http2 versions of these types. This changes tests which exercised configuring the http2 package types to now exercise the net/http configuration path. For example, tests which set http2.Transport.DisableCompression will now set http.Transport.DisableCompression. We don't care about the old http2-internal configuration paths, since they aren't accessible to users. For #67810 Change-Id: I942c6812321fbd24c94b8aa7215dc60d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751302 Reviewed-by: Nicholas Husin <nsh@golang.org> 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>
2026-03-12net/http/internal/http2: make tests passDamien Neil
Remove the "//go:build ignore" lines from the initial import and make the minimal changes required for tests to pass in the new package location. For #67810 Change-Id: I243f4d4a2e269266786a22a7eb8fb17d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751700 Auto-Submit: 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> Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-12net/http/internal/http2: initial importDamien Neil
This copies the contents of golang.org/x/net/http2 at 38019a2dbc2645a4c06a1e983681eefb041171c8 into net/http/internal/http2. Files which are not built at go1.27 (e.g., config_go125.go) are not included. A "//go:build ignore" comment has been added to each file. For #67810 Change-Id: If3e52767eea31adf4e2fdcff0dfa67e46a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751300 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-11net/http: document which headers Request.Write handles speciallykovan
Document that Header values for Host, Content-Length, Transfer-Encoding, and Trailer are not used by Write, as these are derived from other Request fields. Also document that User-Agent defaults to "Go-http-client/1.1" if not set in Header. Fixes #68635 Change-Id: Ie182777ae094657cf3971fed989af1bd5e875d9f Reviewed-on: https://go-review.googlesource.com/c/go/+/741442 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2026-03-11net/http: add pluggable HTTP/3 support for closing idle connectionsNicholas S. Husin
This CL defines the closeIdleConectionser interface, allowing us to call a CloseIdleConnections method that a pluggable HTTP/3 transport might implement. Concretely, this allows an HTTP/3 transport implementation to clean up resources such as an open UDP socket that is no longer needed, preventing resources from lingering around indefinitely until the entire program exits. For #77440 Change-Id: I7216caee58954c3651f96a56dbf27ec74c539ad3 Reviewed-on: https://go-review.googlesource.com/c/go/+/753161 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-04net/http: restore accidentally removed package docDamien Neil
Remove a blank line which accidentally crept in between the package doc comment and the package line. Fixes #77948 Change-Id: I6b513c1e9ea97d2a4b3c6f7b9b10092a6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/751520 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>
2026-03-04net/http: add basic unexported pluggable HTTP/3 supportNicholas S. Husin
Following #77440, this CL adds a basic support for plugging in an HTTP/3 implementation to net/http. As the proposal is not accepted yet, this CL does not add any exported symbols. Access to plug HTTP/3 support is locked behind net/http.protocolSetHTTP3, which can only be used via linkname by golang.org/x/net/internal/http3_test.protocolSetHTTP3. This will allow us to run our HTTP/3 implementation in x/net againts various tests in net/http to support development, without expanding the API surface for any users. Support for closeIdleConnectionser will be added separately in the future. For #77440 Change-Id: I6e3a0c2e9b329cef43e4682463ed5e2093d04256 Reviewed-on: https://go-review.googlesource.com/c/go/+/740120 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-19net/url: add (*URL).CloneEmmanuel T Odeke
This change adds URL.Clone which creates a deep copy of the URL's fields including the .User and tests these. In a separate CL I shall send Values.Clone too. Updates #73450 Change-Id: Ifea4bfc4ddd0640247544ec111ec83bd9bbe9104 Reviewed-on: https://go-review.googlesource.com/c/go/+/746800 Reviewed-by: Nicholas Husin <husin@google.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2026-02-06net/http: fix WaitGroup race in TestTransportNoReuseAfterEarlyResponseDmitri Shuralyov
The remaining race reported in go.dev/issue/66519 is that it's possible for copying.Wait to start running before all copying.Add calls complete. It happens infrequently as is, but padding both Wait and Add calls with a 100 ms sleep makes it highly reproducible. Arranging the Add call to happen before responding "foo" to the POST request should be enough to guarantee that Wait doesn't start running until all Add calls have already happened. While here, delete a blank line that gets more in the way of reading error handling code than it helps. For #64252. Fixes #66519 (optimistically). Change-Id: Ibf264d8cc5ffc2495e8ae8e66a15591310c65e71 Reviewed-on: https://go-review.googlesource.com/c/go/+/739060 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2026-02-06net/http: remove hasPort and simplify logicJorropo
Fixes #76651 Change-Id: I306e127375095bc0caedb01ac458107cfec5f085 Reviewed-on: https://go-review.googlesource.com/c/go/+/725740 Auto-Submit: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
2026-02-04net/http: use SplitSeq in ParseCookieCarlo Alberto Ferraris
goos: linux goarch: amd64 pkg: net/http cpu: 12th Gen Intel(R) Core(TM) i7-12700 │ master.txt │ patch.txt │ │ sec/op │ sec/op vs base │ ReadCookies/readCookies-20 1.499µ ± 1% 1.482µ ± 3% ~ (p=0.197 n=10) ReadCookies/ParseCookie-20 1.552µ ± 2% 1.437µ ± 2% -7.44% (p=0.000 n=10) geomean 1.525µ 1.459µ -4.34% │ master.txt │ patch.txt │ │ B/op │ B/op vs base │ ReadCookies/readCookies-20 1.953Ki ± 0% 1.953Ki ± 0% ~ (p=1.000 n=10) ¹ ReadCookies/ParseCookie-20 2.109Ki ± 0% 1.953Ki ± 0% -7.41% (p=0.000 n=10) geomean 2.030Ki 1.953Ki -3.77% ¹ all samples are equal │ master.txt │ patch.txt │ │ allocs/op │ allocs/op vs base │ ReadCookies/readCookies-20 11.00 ± 0% 11.00 ± 0% ~ (p=1.000 n=10) ¹ ReadCookies/ParseCookie-20 12.00 ± 0% 11.00 ± 0% -8.33% (p=0.000 n=10) geomean 11.49 11.00 -4.26% ¹ all samples are equal Change-Id: I7e84d52ac8d25991595d1b0480334fe9d1a84ffb Reviewed-on: https://go-review.googlesource.com/c/go/+/727520 Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Carlos Amedee <carlos@golang.org>
2026-02-04net/http/httptrace: compose ClientTrace without reflectRandy Reddig
This is to enable use of package httptrace on TinyGo, which does not have an implementation of reflect.MakeFunc. Change-Id: I4f1f94352797bfe3553c1c2d4d1d3dca44b03e43 GitHub-Last-Rev: 4587368ad875bd55e6a8cbdcd7e13738a8d02400 GitHub-Pull-Request: golang/go#69172 Reviewed-on: https://go-review.googlesource.com/c/go/+/609763 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev>
2026-02-03net/http: prevent blocking when draining response body after it has been closedNicholas S. Husin
Previously, draining the response body after it has been closed causes Response.Body.Close to block for longer than it otherwise would. In a worst-case scenario, this means that we are incurring a 50 ms delay for each HTTP/1 request that we make. This CL makes sure that a response body is drained asynchronously and updates relevant documentations to reflect the current behavior. For #77370 Change-Id: I2486961bc1ea3d43d727d0aabc7a6ca7dfb166ee Reviewed-on: https://go-review.googlesource.com/c/go/+/741222 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-02net/http: try to drain response body upon closing for better connection re-useNicholas S. Husin
Currently, we have a rather inconsistent behavior in terms of whether a connection can be re-used or not when an HTTP body is not read to completion: - In HTTP/2, not reading bodies to completion is not an issue, since a new HTTP/2 stream can be created on the same TCP connection. - In HTTP/1 server, we discard up to 256 KiB of unconsumed request body, to potentially allow re-use. - In HTTP/1 client, we do not do anything, and fail to re-use a TCP connection if there are any unconsumed response body at all. This has led to some confusion. For example, some users have mistakenly discarded response body for HTTP/2 when doing so is not needed. Manually discarding response body can also be disadvantageous if the body is excessively large or is a never-ending stream. To solve this issue, this CL makes it so that closing a response body will cause any remaining content to be drained, up to a limit of 256 KiB or 50 milliseconds, whichever one is reached first. This allows better connection re-use for HTTP/1, and most users can now avoid having to manually drain their response body. For #77370 Change-Id: I71e1227fc9cf5f901362c8e234320817f6b0be24 Reviewed-on: https://go-review.googlesource.com/c/go/+/737720 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-23all: update vendored dependenciesNicholas S. Husin
This CL does the following: 1. Bundles up golang.org/x/net/internal/httpsfv since h2_bundle.go now relies on it. 2. Modifies h2_bundle.go import mapping to account for httpsfv package. 3. Updates all vendored dependencies using golang.org/x/build/cmd/updatestd. For #75500 Change-Id: Ia2f41ad606092fe20b62f946266190502b146977 Reviewed-on: https://go-review.googlesource.com/c/go/+/738621 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-01-22net/http: Add Server.DisableClientPriority fieldNicholas S. Husin
The DisableClientPriority field is currently still a no-op, and will only take effect once golang.org/x/net is bundled up into h2_bundle.go again. For #75500 Change-Id: I9e2135bed50b7f201aea93467e3f5f5f6c81cb1c Reviewed-on: https://go-review.googlesource.com/c/go/+/738620 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-22net/http: use math/rand/v2 instead of math/rand1911860538
math/rand/v2 provides a more modern, performant, and secure random number API. Change-Id: Ic0c30ae40623508e3ed65c435be3c208704b5655 GitHub-Last-Rev: a8fa520b39cb5cc56042b74f6c40163bf8115247 GitHub-Pull-Request: golang/go#76433 Reviewed-on: https://go-review.googlesource.com/c/go/+/723680 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com>