aboutsummaryrefslogtreecommitdiff
path: root/src/net
AgeCommit message (Collapse)Author
2025-06-27net/http: fix RoundTrip context cancellation for js/wasmAndy Nitschke
The existing js/wasm implementation of RoundTrip calls abort() on the fetch() call when the context is canceled but does not wait for for the resulting promise to be rejected. The result is the failure callback for the promise will be called at some later point in time when the promise rejection is handled. In some case this callback may be called after the Go program has exited resulting in "Go program has already exited" errors. Fixes #57098 Change-Id: Ia37fd22cb9f667dbb0805ff5db0ceb8fdba7246b Reviewed-on: https://go-review.googlesource.com/c/go/+/680937 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-24net/http: reduce allocs in CrossOriginProtection.CheckJulien Cretel
Rather than repeatedly creating error values on CrossOriginProtection.Check's unhappy paths, return non-exported and effectively constant error variables. For #73626. Change-Id: Ibaa036c29417071b3601b8d200ab0902359d1bb9 GitHub-Last-Rev: e704d63cd63665845d544796e802134ea608e217 GitHub-Pull-Request: golang/go#74251 Reviewed-on: https://go-review.googlesource.com/c/go/+/681178 Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-12net: remove some BUG entriesCherry Mui
A few methods that were not implemented on Windows are implemented in CL 668195. Change-Id: I35423792a5af00f29fcd24e56a6dfcf013669371 Reviewed-on: https://go-review.googlesource.com/c/go/+/680180 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-06-10net/http: make the zero value of CrossOriginProtection workAustin Clements
Currently, CrossOriginProtection must be constructed by NewCrossOriginProtection. If you try to use the zero value, most methods will panic with a nil dereference. This CL makes CrossOriginProtection use on-demand initialization instead, so the zero value has the same semantics as the value currently returned by NewCrossOriginProtection. Now, NewCrossOriginProtection just constructs the zero value. We keep NewCrossOriginProtection by analogy to NewServeMux. Updates #73626 Fixes #74089. Change-Id: Ia80183eb6bfdafb0e002271c0b25c2d6230a159a Reviewed-on: https://go-review.googlesource.com/c/go/+/680396 Auto-Submit: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-06-06all: update vendored dependencies [generated]Carlos Amedee
The Go 1.25 RC is due soon. This is the time to once again update all golang.org/x/... module versions that contribute packages to the std and cmd modules in the standard library to latest master versions. For #36905. [git-generate] go install golang.org/x/build/cmd/updatestd@latest go install golang.org/x/tools/cmd/bundle@latest updatestd -goroot=$(pwd) -branch=master cat << EOF | patch diff --git a/src/cmd/go/testdata/script/test_json_build.txt b/src/cmd/go/testdata/script/test_json_build.txt index df8863ae03..2a572ace72 100644 --- a/src/cmd/go/testdata/script/test_json_build.txt +++ b/src/cmd/go/testdata/script/test_json_build.txt @@ -56,7 +56,7 @@ stdout '"Action":"fail","Package":"m/cycle/p","Elapsed":.*,"FailedBuild":"m/cycl ! go test -json -o=$devnull ./veterror stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# m/veterror\\n"' stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# \[m/veterror\]\\n"' -stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror(/|\\\\)main_test.go:9:9: fmt.Printf format %s reads arg #1, but call has 0 args\\n"' +stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"veterror(/|\\\\)main_test.go:9:21: fmt.Printf format %s reads arg #1, but call has 0 args\\n"' stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-fail"' stdout '"Action":"start","Package":"m/veterror"' stdout '"Action":"output","Package":"m/veterror","Output":"FAIL\\tm/veterror \[build failed\]\\n"' EOF Change-Id: I6a8d35acdeab90c3bbd6395b8b1abb021673b5cb Reviewed-on: https://go-review.googlesource.com/c/go/+/678556 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-06-05net/http: strip sensitive proxy headers from redirect requestsNeal Patel
Similarly to Authentication entries, Proxy-Authentication entries should be stripped to ensure sensitive information is not leaked on redirects outside of the original domain. https://fetch.spec.whatwg.org/#authentication-entries Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this issue. For #73816 Fixes CVE-2025-4673 Change-Id: Ied7b641f6531f1d340ccba3c636d3c30dd5547d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/679257 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-23net: use runtime.AddCleanup instead of runtime.SetFinalizerCarlos Amedee
Adds TODO for replacement of runtime.SetFinalizer. Fixes #70907 Change-Id: Ic009018a93ccc46a776ae34afac44635d2340cbf Reviewed-on: https://go-review.googlesource.com/c/go/+/638557 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Carlos Amedee <carlos@golang.org>
2025-05-23net/http: document that ServeMux.Handler can also synthetize a 405Filippo Valsorda
Also, fix a minor typo in ServeMux.Handle and ServeMux.HandleFunc. Change-Id: I6a6a46565719104cb8f2484daf0e39f35b55a078 Reviewed-on: https://go-review.googlesource.com/c/go/+/675835 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-21net/http: use synctest.Test rather than RunDamien Neil
Use the non-experimental Test function. As a bonus, this lets us drop the hacks we were doing to support t.Cleanup inside bubbles. Change-Id: I070624e1384494e9d5fcfee594cfbb7680c1beda Reviewed-on: https://go-review.googlesource.com/c/go/+/675315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2025-05-21net/http: add CrossOriginProtectionFilippo Valsorda
Fixes #73626 Change-Id: I6a6a4656862e7a38acb65c4815fb7a1e04896172 Reviewed-on: https://go-review.googlesource.com/c/go/+/674936 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-05-20net: avoid using Windows' TransmitFile on non-server machinesShibi J M
Windows API's TransmitFile function is limited to two concurrent operations on workstation and client versions of Windows. This change modifies the net.sendFile function to perform no work in such cases so that TransmitFile is avoided. Fixes #73746 Change-Id: Iba70d5d2758bf986e80c78254c8e9e10b39bb368 GitHub-Last-Rev: 315ddc0cd8034f52632dc31baf35057a8bad9bcd GitHub-Pull-Request: golang/go#73758 Reviewed-on: https://go-review.googlesource.com/c/go/+/673855 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-05-20net/http: upon http redirect, copy Request.GetBody in new requestMarc-Antoine Ruel
This enable http.RoundTripper implementation to retry POST request (let's say after a 500) after a 307/308 redirect. Fixes #73439 Change-Id: I4365ff58b012c7f0d60e0317a08c98b1d48f657e Reviewed-on: https://go-review.googlesource.com/c/go/+/666735 Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-05-19net/http: clarify ServeMux.Handler behaviorJonathan Amsterdam
Explain that ServeMux.Handler doesn't populate the request with matches. Fixes #69623. Change-Id: If625b3f8e8f4e54b05e1d9a86e8c471045e77763 Reviewed-on: https://go-review.googlesource.com/c/go/+/674095 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Chressie Himpel <chressie@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-19net/http: fix ServeMux.Handler on trailing-slash redirectJonathan Amsterdam
When a match involves a trailing-slash redirect, ServeMux.Handler now returns the pattern that matched. Fixes #73688. Change-Id: I682d9cc9a3628bed8bf21139b98369ffa6c53792 Reviewed-on: https://go-review.googlesource.com/c/go/+/673815 Reviewed-by: Filippo Valsorda <filippo@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-05-15net: avoid windows hang in TestCloseWriteqmuntal
On Windows, reading from a socket at the same time as the other end is closing it will occasionally hang. This is a Windows issue, not a Go issue, similar to what happens in macOS (see #49352). Work around this condition by adding a brief sleep before the read. Fixes #73140. Change-Id: I24e457a577e507d0d69924af6ffa1aa24c4aaaa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/671457 Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-05-14net: use closesocket when closing socket os.File's on Windowsqmuntal
The WSASocket documentation states that the returned socket must be closed by calling closesocket instead of CloseHandle. The different File methods on the net package return an os.File that is not aware that it should use closesocket. Ideally, os.NewFile should detect that the passed handle is a socket and use the appropriate close function, but there is no reliable way to detect that a handle is a socket on Windows (see CL 671455). To work around this, we add a hidden function to the os package that can be used to return an os.File that uses closesocket. This approach is the same as used on Unix, which also uses a hidden function for other purposes. While here, fix a potential issue with FileConn, which was using File.Fd rather than File.SyscallConn to get the handle. This could result in the File being closed and garbage collected before the syscall was made. Fixes #73683. Change-Id: I179405f34c63cbbd555d8119e0f77157c670eb3e Reviewed-on: https://go-review.googlesource.com/c/go/+/672195 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-12net: don't test with leading 0 in ipv4 addressesSean Liao
Updates #30999 Fixes #73378 Change-Id: I6a96581e78678518473626aa5d108428cfad6619 Reviewed-on: https://go-review.googlesource.com/c/go/+/671795 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-05-12net: fix deadlock in lookupProtocol on WindowsSpike Curtis
If the context expires before acquireThread(ctx) succeeds, then the goroutine can block like: net.lookupProtocol.func1() src/net/lookup_windows.go:58 +0x105 created by net.lookupProtocol in goroutine 2834 src/net/lookup_windows.go:56 +0xda We saw this in our UTs with a leak detector, confirmed by inspection of the source code. Change-Id: I9b927f0345a2fa7336b23d95c506a8a0976e28d0 GitHub-Last-Rev: 27af7477a99bdbee0c32697837f1ff261ee70d83 GitHub-Pull-Request: golang/go#73364 Reviewed-on: https://go-review.googlesource.com/c/go/+/664956 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Zxilly Chou <zhouxinyu1001@gmail.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-12net/http: add missing ServeTLS on the comment of http.Server.Shutdownt-katsumura
A sentinel error http.ErrServerClosed is returned after Server.Shutdown and Server.Close but it is not documented on the Server.Shutdown while other methods such as Server.Serve are documented on it. Change-Id: Id82886d9d6a1474a514d62e9169b35f3579a9eee Reviewed-on: https://go-review.googlesource.com/c/go/+/671695 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Sean Liao <sean@liao.dev>
2025-05-05net,os: support converting between *os.File and net.Conn on Windowsqmuntal
The runtime poller and os.NewFile recently gained support for disassociating the handle from the runtime poller IOCP (see CL 664455). This was the main blocker for allowing the conversion between *os.File and net.Conn. Implementing the conversion is now trivial. The only remaining work, implemented in this CL, is improving os.NewFile to also support socket handles and updating some build tags so that Windows can share almost the same net's File implementation as Unix. There is one important limitation, though: the duplicated socket handle returned by the various File methods in the net package is not usable on other process. If someone needs to pass a socket handle to another process, they should manually call the WSADuplicateSocket Windows API passing the process ID of the target process. Fixes #9503. Fixes #10350. Updates #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: Ic43cadaac2662b925d57a9d362ddc7ae21d1b56e Reviewed-on: https://go-review.googlesource.com/c/go/+/668195 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-30net: support IPv6 addresses in ListenMulticastUDP on Windowsqmuntal
Fixes #63529. Change-Id: Id9246af1a72beef3149af571f0891437bba2f4e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/668216 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2025-04-23cmd/vendor: update x/tools and x/textAlan Donovan
This CL updates x/tools to 68e94bd and x/text to v0.24.0, updates the vendor tree, and re-runs the bundle step for net/http. Updates golang/go#28308 Change-Id: I4184f77547f535270ddc8e2ce6542377e3046ffd Reviewed-on: https://go-review.googlesource.com/c/go/+/667597 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Auto-Submit: Alan Donovan <adonovan@google.com>
2025-04-22net/http: replace map lookup with switch for scheme port1911860538
Improve scheme port lookup by replacing map with switch, reducing overhead and improving performance. Change-Id: I45c790da15e237d5f32c50d342b3713b98fd2ffa GitHub-Last-Rev: 4c02e4cabf181b365fbf2b722e3051625a289527 GitHub-Pull-Request: golang/go#73422 Reviewed-on: https://go-review.googlesource.com/c/go/+/666356 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-04-19net: simplify readProtocols via sync.OnceFunc1911860538
In this case, using sync.OnceFunc is a better choice. Change-Id: I52d27b9741265c90300a04a03537020e1aaaaaa7 GitHub-Last-Rev: a281daea255f1508a9042e8c8c7eb7ca1cef2430 GitHub-Pull-Request: golang/go#73434 Reviewed-on: https://go-review.googlesource.com/c/go/+/666635 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2025-04-16net/http: add test for proxyAuthzxc111
Change-Id: Ib4edae749ce8da433e992e08a90c9cf3d4357081 GitHub-Last-Rev: 19d87d12ab6b299b37e8907429f4dff52ab53745 GitHub-Pull-Request: golang/go#46102 Reviewed-on: https://go-review.googlesource.com/c/go/+/318690 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-16net/url: clarify why @ is allowed in userinfo1911860538
Add comment to clarify why '@' is allowed in validUserinfo func. Change-Id: Ia9845bc40fea6c34093434d57bb1be4ddbc70b84 GitHub-Last-Rev: ce65168ab03afd879ad028de295f6adb7ee1c97d GitHub-Pull-Request: golang/go#73195 Reviewed-on: https://go-review.googlesource.com/c/go/+/663455 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: Damien Neil <dneil@google.com>
2025-04-16net/http: set Request.TLS when net.Conn implements ConnectionStateWeidi Deng
Fixes #56104 Change-Id: I8fbbb00379e51323e2782144070cbcad650eb6f1 GitHub-Last-Rev: 62d7a8064e4f2173f0d8e02ed91a7e8de7f13fca GitHub-Pull-Request: golang/go#56110 Reviewed-on: https://go-review.googlesource.com/c/go/+/440795 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-15net/http: test intended behavior in TestClientInsecureTransportDamien Neil
This test wasn't testing the HTTP/2 case, because it didn't set NextProtos in the tls.Config. Set "Connection: close" on requests to make sure each request gets a new connection. Change-Id: I1ef470e7433a602ce88da7bd7eeec502687ea857 Reviewed-on: https://go-review.googlesource.com/c/go/+/655676 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2025-04-14internal/poll: disable SIO_UDP_NETRESET on WindowsJames Tucker
Disable the reception of NET_UNREACHABLE (TTL expired) message reporting on UDP sockets to match the default behavior of sockets on other plaforms. See https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#sio_udp_netreset This is similar to, but a different case from the prior change 3114bd6 / https://golang.org/issue/5834 that disabled one of the two flags influencing behavior in response to the reception of related ICMP. Updates #5834 Updates #68614 Change-Id: I39bc77ab68f5edfc14514d78870ff4a24c0f645e GitHub-Last-Rev: 78f073bac226aeca438b64acc2c66f76c25f29f8 GitHub-Pull-Request: golang/go#68615 Reviewed-on: https://go-review.googlesource.com/c/go/+/601397 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2025-04-10net: deduplicate sendfile filesqmuntal
The sendfile implementation for platforms supporting it is now in net/sendfile.go, rather than being duplicated in separate files for each platform. The only difference between the implementations was the poll.SendFile parameters, which have been harmonized, and also linux strictly asserting for os.File, which now have been relaxed to allow any type implementing syscall.Conn. Change-Id: Ia1a2d5ee7380710a36fc555dbf681f7e996ea2ec Reviewed-on: https://go-review.googlesource.com/c/go/+/664075 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2025-04-10net: reenable sendfile on Windowsqmuntal
Windows sendfile optimization is skipped since CL 472475, which started passing an os.fileWithoutWriteTo instead of an os.File to sendfile, and that function was only implemented for os.File. This CL fixes the issue by asserting against an interface rather than a concrete type. Some tests have been reenabled, triggering bugs in poll.SendFile which have been fixed in this CL. Fixes #67042. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest Change-Id: Id6f7a0e1e0f34a72216fa9d00c5bf36f5a994219 Reviewed-on: https://go-review.googlesource.com/c/go/+/664055 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2025-04-09net/http: initialize Value with File length in cloneMultipartForm1911860538
Improve the initialization of the Value map in cloneMultipartForm by utilizing the length of the File map to optimize memory allocation. Change-Id: I97ba9e19b2718a75c270e6df21306f4c82656c71 GitHub-Last-Rev: a9683ba9a7cbb20213766fba8d9096b4f8591d86 GitHub-Pull-Request: golang/go#69943 Reviewed-on: https://go-review.googlesource.com/c/go/+/621235 Reviewed-by: Christian Ekrem <christianekrem@gmail.com> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-09net/http: reduce memory usage when hijackingJakob Ackermann
Previously, Hijack allocated a new write buffer and the existing connection write buffer used an extra 4KiB of memory until the handler finished and the "conn" was garbage collected. Now, hijack re-uses the existing write buffer and re-attaches it to the raw connection to avoid referencing the net/http "conn" after returning. After a handler that hijacked exited, the "conn" reference in "connReader" will now be unset. This allows all of the "conn", "response" and "Request" to get garbage collected. Overall, this is reducing the memory usage by 43% or 6.7KiB per hijacked connection (see BenchmarkServerHijackMemoryUsage in an earlier revision of the CL). CloseNotify will continue to work _before_ the handler has exited (i.e. while the "conn" is still referenced in "connReader"). This aligns with the documentation of CloseNotifier: > After the Handler has returned, there is no guarantee that the channel > receives a value. goos: linux goarch: amd64 pkg: net/http cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz │ before │ after │ │ sec/op │ sec/op vs base │ ServerHijack-8 42.59µ ± 8% 39.47µ ± 16% ~ (p=0.481 n=10) │ before │ after │ │ B/op │ B/op vs base │ ServerHijack-8 16.12Ki ± 0% 12.06Ki ± 0% -25.16% (p=0.000 n=10) │ before │ after │ │ allocs/op │ allocs/op vs base │ ServerHijack-8 51.00 ± 0% 49.00 ± 0% -3.92% (p=0.000 n=10) Change-Id: I20a37ee314ed0d47463a4657d712154e78e48138 GitHub-Last-Rev: 80f09dfa273035f53cdd72845e5c5fb129c3e230 GitHub-Pull-Request: golang/go#70756 Reviewed-on: https://go-review.googlesource.com/c/go/+/634855 Reviewed-by: Sean Liao <sean@liao.dev> 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: Sean Liao <sean@liao.dev>
2025-04-08net/http: push roundTrip panic higher in the stackNeal Patel
If Transport is a non-nil interface pointing to a nil implementer, then a panic inside of roundTrip further obsfucates the issue. Change-Id: I47664b8e6185c5f56b5e529f49022484b5ea1d94 Reviewed-on: https://go-review.googlesource.com/c/go/+/661897 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Neal Patel <nealpatel@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-04-07net/http: add link to typesabemotion
Some types are not linked. This change adds a link to each type. Change-Id: Id46fb64a74efb851ed76e4136f15e8fd9e445bb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/663075 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-07all: use built-in max/min to simplify the codecuishuang
Change-Id: I309d93d6ebf0feb462217a344d5f02c190220752 Reviewed-on: https://go-review.googlesource.com/c/go/+/661737 Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: 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>
2025-04-04internal/syscall/windows: use unsafe.Pointer instead of uintptrqmuntal
Some functions accept a uintptr when they should accept an unsafe.Pointer, else the compiler won't know that the pointer should be kept alive across the call, potentially causing undefined behavior. Fixes #73156 (potentially) Change-Id: I29c847eb8ffbb785fabf217e9f3718d10cfb5047 Reviewed-on: https://go-review.googlesource.com/c/go/+/662855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-26net: run unix socket stream tests on Windowsqmuntal
The net package supports Unix domain sockets on Windows, but most of the tests related to them are skipped. This CL unskip the SOCK_STREAM tests. SOCK_DGRAM probablye can also make to work, but that will come in a follow-up CL. Change-Id: If9506a8af57e9bfe58bd7b48a98fc39335627a61 Reviewed-on: https://go-review.googlesource.com/c/go/+/660915 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-25internal/poll,net: set SIO_UDP_CONNRESET in netqmuntal
Setting the SIO_UDP_CONNRESET option in internal/poll.FD.Init adds unnecessary complexity to the FD.Init signature and implementation. Better to set it in the net package when initializing the UDP connection, which is where conceptually it belongs. While here, update an outdated comment in FD.Init that said the runtime poller doesn't support I/O operations initialized by the user outside the internal/poll package. It does support those operations since CL 561895. For #19098. Updates #21172. Change-Id: I9a70b0deafdb4619830abe2147e2d366b4c2b890 Reviewed-on: https://go-review.googlesource.com/c/go/+/660496 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-24net/url: document referenced RFCsSean Liao
Fixes #30611 Change-Id: If933c2a7e63d89402d2034618057ad546cf9641b Reviewed-on: https://go-review.googlesource.com/c/go/+/660077 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-20net/http/httputil: document ReverseProxy removal of response headersSean Liao
Fixes #30359 Change-Id: I5dfb2cd63c737959fd2f6a0dbf50ff8de18bb15d Reviewed-on: https://go-review.googlesource.com/c/go/+/658535 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-20net/smtp: make test certificate FIPS 140-3 compliantFilippo Valsorda
The key was too small and was getting rejected by crypto/tls if running tests in FIPS 140-3 mode. Change-Id: I6a6a4656374b942aeeca55d5c0464c965db0f6de Reviewed-on: https://go-review.googlesource.com/c/go/+/658935 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-03-19net/http/httputil: don't call WriteHeader after HijackDamien Neil
CL 637939 changed ReverseProxy to report errors encountered when copying data on an hijacked connection. This is generally not useful, and when using the default error handler results in WriteHeader being called on a hijacked connection. While this is harmless with standard net/http ResponseWriter implementations, it can confuse middleware layers. Fixes #72954 Change-Id: I21f3d3d515e114dc5c298d7dbc3796c505d3c82f Reviewed-on: https://go-review.googlesource.com/c/go/+/659255 Reviewed-by: Jonathan Amsterdam <jba@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-18net/http/httputil: document ProxyRequest.SetURL limitationsSean Liao
Fixes #50337 Change-Id: I898ff6352f46f0f9b540b053049c5116e2165827 Reviewed-on: https://go-review.googlesource.com/c/go/+/658536 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-18net/http: add onClose hook to fake net listenerDamien Neil
Avoids a race condition: If we set an onClose hook on a conn created by a listener, then setting the hook can race with the connection closing. Change-Id: Ibadead3abbe4335d41f1e2cf84f4696fe98166b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/658655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-03-12net: deflake recently added TestCloseUnblocksReadUDPBrad Fitzpatrick
Fixes #72802 Change-Id: I0dd457ef81a354f61c9de306e4609efdbe3d69b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/656857 Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Brad Fitzpatrick <bradfitz@golang.org>
2025-03-11net/http: document Redirect behavior for non-ASCII charactersIan Lance Taylor
For #4385 For #72745 Change-Id: Ibd54fc03467eb948001299001bb2e2529512a7c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/656135 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-11net/mail: use sync.OnceValue to build dateLayouts1911860538
Simplify buildDateLayouts with sync.OnceValue. Change-Id: Ib48ab20ee00f5e44cc1b0f6e1afe3fcd1b7dc3c7 GitHub-Last-Rev: 0866d463de1ec618d0d645b98f5e94917b8c3bde GitHub-Pull-Request: golang/go#72743 Reviewed-on: https://go-review.googlesource.com/c/go/+/656055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-11runtime/internal: clean up completelyJes Cok
We've been slowly moving packages from runtime/internal to internal/runtime. For now, runtime/internal only has test packages. It's a good chance to clean up the references to runtime/internal in the toolchain. For #65355. Change-Id: Ie6f9091a44511d0db9946ea6de7a78d3afe9f063 GitHub-Last-Rev: fad32e2e81d11508e734c3c3d3b0c1da583f89f5 GitHub-Pull-Request: golang/go#72137 Reviewed-on: https://go-review.googlesource.com/c/go/+/655515 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-03-11net: unblock UDP Reads upon Close on plan9, add testBrad Fitzpatrick
Fixes #72770 Change-Id: I42be7c7349961188f4b5d73287a3550aba323893 Reviewed-on: https://go-review.googlesource.com/c/go/+/656395 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Russ Cox <rsc@golang.org>