aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
AgeCommit message (Collapse)Author
2024-12-19net/http: fix nil panic in testRuss Cox
Observed on a builder in an unrelated CL. https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8728107031663629713/+/u/step/11/log/2 goroutine 27937 gp=0xc00000f6c0 m=20 mp=0xc000085008 [running]: panic({0x560ac0?, 0xa1f400?}) C:/b/s/w/ir/x/w/goroot/src/runtime/panic.go:806 +0x168 fp=0xc00043fac8 sp=0xc00043fa18 pc=0xa5f88 testing.tRunner.func1.2({0x560ac0, 0xa1f400}) C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1734 +0x219 fp=0xc00043fb78 sp=0xc00043fac8 pc=0x1537f9 testing.tRunner.func1() C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1737 +0x359 fp=0xc00043fce0 sp=0xc00043fb78 pc=0x153259 panic({0x560ac0?, 0xa1f400?}) C:/b/s/w/ir/x/w/goroot/src/runtime/panic.go:787 +0x132 fp=0xc00043fd90 sp=0xc00043fce0 pc=0xa5f52 runtime.panicmem(...) C:/b/s/w/ir/x/w/goroot/src/runtime/panic.go:262 runtime.sigpanic() C:/b/s/w/ir/x/w/goroot/src/runtime/signal_windows.go:401 +0x198 fp=0xc00043fdd8 sp=0xc00043fd90 pc=0x87938 net/http_test.testTransportIdleConnTimeout.func3(...) C:/b/s/w/ir/x/w/goroot/src/net/http/transport_test.go:5503 net/http_test.testTransportIdleConnTimeout(0xc000e83340, {0x5ec863, 0x2}) C:/b/s/w/ir/x/w/goroot/src/net/http/transport_test.go:5522 +0x4c1 fp=0xc00043ff20 sp=0xc00043fdd8 pc=0x47a841 net/http_test.run[...].func1() C:/b/s/w/ir/x/w/goroot/src/net/http/clientserver_test.go:93 +0xfe fp=0xc00043ff70 sp=0xc00043ff20 pc=0x49a21e testing.tRunner(0xc000e83340, 0xc0004687b0) C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1792 +0xcb fp=0xc00043ffc0 sp=0xc00043ff70 pc=0x152e4b testing.(*T).Run.gowrap1() C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1851 +0x25 fp=0xc00043ffe0 sp=0xc00043ffc0 pc=0x153e65 runtime.goexit({}) C:/b/s/w/ir/x/w/goroot/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00043ffe8 sp=0xc00043ffe0 pc=0xadfe1 created by testing.(*T).Run in goroutine 27899 C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1851 +0x3f6 Change-Id: I3f8bd7c7863b5031ff43d4837dfe11d26ac75652 Reviewed-on: https://go-review.googlesource.com/c/go/+/637897 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-11net/http: document zero value of ProtocolsDamien Neil
For #67814 Change-Id: I182e9c7e720493adb9d2384336e757dace818525 Reviewed-on: https://go-review.googlesource.com/c/go/+/635335 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Austin Clements <austin@google.com>
2024-12-06all: update vendored dependencies [generated]Michael Anthony Knyszek
The Go 1.24 RC is due for next week. This is a 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 Change-Id: If4fd03a18590ff3b6e701a9698370c57c69979c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/634041 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-26net/http: test for racing idle conn closure and new requestsDamien Neil
TestTransportRemovesH2ConnsAfterIdle is experiencing flaky failures due to a bug in idle connection handling. Upon inspection, TestTransportRemovesH2ConnsAfterIdle is slow and (I think) not currently testing the condition that it was added to test. Using the new synctest package, this CL: - Adds a test for the failure causing flakes in this test. - Rewrites the existing test to use synctest to avoid sleeps. - Adds a new test that covers the condition the test was intended to examine. The new TestTransportIdleConnRacesRequest exercises the scenario where a never-used connection is closed by the idle-conn timer at the same time as a new request attempts to use it. In this race, the new request should either successfully use the old connection (superseding the idle timer) or should use a new connection; it should not use the closing connection and fail. TestTransportRemovesConnsAfterIdle verifies that a connection is reused before the idle timer expires, and not reused after. TestTransportRemovesConnsAfterBroken verifies that a connection is not reused after it encounters an error. This exercises the bug fixed in CL 196665, which introduced TestTransportRemovesH2ConnsAfterIdle. For #70515 Change-Id: Id23026d2903fb15ef9a831b2df71177ea177b096 Reviewed-on: https://go-review.googlesource.com/c/go/+/631795 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2024-11-25net/http: run TestServerShutdownStateNew in a synctest bubbleDamien Neil
Took ~12s previously, ~0s now. Change-Id: I72580fbde73482a40142cf84cd3d78a50afb9f44 Reviewed-on: https://go-review.googlesource.com/c/go/+/630382 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-11-25net/http: avoid redundant installation of HTTP/2 support in transportDamien Neil
Previously, we'd skip installing the bundled HTTP/2 support if Transport.TLSNextProto is non-nil. With the addition of the Transport.Protocols field, we'll install HTTP/2 if Protocols contains HTTP2, even if TLSNextProto is non-nil. However, we shouldn't do so if it already contains an "h2" entry. Change-Id: Ib086473bb52f1b76d83b1df961d41360c605832c Reviewed-on: https://go-review.googlesource.com/c/go/+/631395 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>
2024-11-22all: update vendored dependencies [generated]Dmitri Shuralyov
The Go 1.24 code freeze has recently started. This is a time to 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 Change-Id: I1b2e3b63ccc1137256d80c882b99ed26a66cbf6b Reviewed-on: https://go-review.googlesource.com/c/go/+/631336 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
2024-11-22net/http: re-enable TestTransportServerProtocolsDmitri Shuralyov
The h2_bundle.go update was done in CL 631035, and the test now passes. Fixes #67816. Change-Id: Icd54c2774a9e2781e7dc9342ae70c3034eb9bab9 Reviewed-on: https://go-review.googlesource.com/c/go/+/631037 Auto-Submit: Damien Neil <dneil@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> 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>
2024-11-22all: update golang.org/x/net [generated]Dmitri Shuralyov
A part of the keeping Go's vendored dependencies and generated code up to date. This updates h2_bundle.go with unencrypted HTTP/2 support. For #36905. For #67816. [git-generate] cd src go get golang.org/x/net@v0.31.0 go mod tidy go mod vendor cd cmd go get golang.org/x/net@v0.31.0 go mod tidy go mod vendor go generate -run=bundle std Change-Id: I2b77f651b990f260fbe7d551c7a819518f1c983f Reviewed-on: https://go-review.googlesource.com/c/go/+/631035 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>
2024-11-22net/http: skip test which depends on h2_bundle.go updateDamien Neil
For #67816 Change-Id: I9ba3a245d6b18758944ca5e206a15892b2aa6028 Reviewed-on: https://go-review.googlesource.com/c/go/+/630976 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Damien Neil <dneil@google.com>
2024-11-21net/http: add support for unencrypted HTTP/2Damien Neil
Add an UnencryptedHTTP2 protocol value. Both Server and Transport implement "HTTP/2 with prior knowledge" as described in RFC 9113, section 3.3. Neither supports the deprecated HTTP/2 upgrade mechanism (RFC 7540, section 3.2 "h2c"). For Server, UnencryptedHTTP2 controls whether the server will accept HTTP/2 connections on unencrypted ports. When enabled, the server checks new connections for the HTTP/2 preface and routes them appropriately. For Transport, enabling UnencryptedHTTP2 and disabling HTTP1 causes http:// requests to be made over unencrypted HTTP/2 connections. For #67816 Change-Id: I2763c4cdec1c2bc6bb8157edb93b94377de8a59b Reviewed-on: https://go-review.googlesource.com/c/go/+/622976 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-11-21all: fix some function names and typos in commentcuishuang
Change-Id: I07e7c8eaa5bd4bac0d576b2f2f4cd3f81b0b77a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/630055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-11-18net/http/httputil: return after handling errorSean Liao
Fixes #70237 Change-Id: Ieb22b6e7284cb4a40d4987b0e4b9cfb6e5158161 Reviewed-on: https://go-review.googlesource.com/c/go/+/627635 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>
2024-11-06net/http: 308 redirects should use the previous hop's bodyDamien Neil
On a 301 redirect, the HTTP client changes the request to be a GET with no body. On a 308 redirect, the client leaves the request method and body unchanged. A 308 following a 301 should preserve the rewritten request from the first redirect: GET with no body. We were preserving the method, but sending the original body. Fix this. Fixes #70180 Change-Id: Ie20027a6058a82bfdffc7197d07ac6c7f98099e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/626055 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-06net/http: handle new HTTP/2 error for 1xx limit exceededDamien Neil
CL 615295 changed the error message produced by the HTTP/2 implementation when a server sends more 1xx headers than expected. Update a test that checks for this error. For #65035 Change-Id: I57e22f6a880412e3a448e58693127540806d5ddb Reviewed-on: https://go-review.googlesource.com/c/go/+/625195 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-05net/http: add Protocols field to Server and TransportDamien Neil
Support configuring which HTTP version(s) a server or client use via an explicit set of protocols. The Protocols field takes precedence over TLSNextProto and ForceAttemptHTTP2. Fixes #67814 Change-Id: I09ece88f78ad4d98ca1f213157b5f62ae11e063f Reviewed-on: https://go-review.googlesource.com/c/go/+/607496 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2024-10-31net/http: clarify ServeMux path sanitizationSean Liao
For #70130 Change-Id: Idd7ca3d11b78887709b83dd5c868de9cc506ecff Reviewed-on: https://go-review.googlesource.com/c/go/+/623835 Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-10-25net/http/pprof: replace sort.Slice with slices.SortFuncRuslan Semagin
Change-Id: Ie416ed0d7abcb64e63d999b8cee5975a0fc13875 Reviewed-on: https://go-review.googlesource.com/c/go/+/622496 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-10-25net/http/pprof: fix typo in the symbol profile descriptionOleksandr Redko
Change-Id: I55e1c559bc73537c8cd42c213c56e2ddaf33aa44 Reviewed-on: https://go-review.googlesource.com/c/go/+/622097 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-10-24net/http: limit 1xx based on size, do not limit when deliveredDamien Neil
Replace Transport's limit of 5 1xx responses with a limit based on MaxResponseHeaderBytes: The total number of responses (including 1xx reponses and the final response) must not exceed this value. When the user is reading 1xx responses using a Got1xxResponse client trace hook, disable the limit: Each 1xx response is individually limited by MaxResponseHeaderBytes, but there is no limit on the total number of responses. The user is responsible for imposing a limit if they want one. For #65035 Change-Id: If4bbbbb0b808cb5016701d50963c89f0ce1229f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/615255 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-23net/http/pprof: include Symbol in IndexSean Liao
Fixes #69897 Change-Id: I5887f34504b39018e16f269e087b43bc6a80964b Reviewed-on: https://go-review.googlesource.com/c/go/+/620455 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-10-07crypto/rand: remove /dev/urandom fallback and improve getrandom batchingFilippo Valsorda
The fallback was reachable on - Linux, where starting in Go 1.24 we require a kernel with getrandom(2), see #67001. - FreeBSD, which added getrandom(2) in FreeBSD 12.0, which we require since Go 1.19. - OpenBSD, which added getentropy(2) in OpenBSD 5.6, and we only support the latest version. - DragonFly BSD, which has getrandom(2) and where we support only the latest version. - NetBSD, where we switched to kern.arandom in CL 511036, available since NetBSD 4.0. - illumos, which has getrandom(2). (Supported versions unclear.) - Solaris, which had getrandom(2) at least since Oracle Solaris 11.4. - AIX, which... ugh, fine, but that code is now in rand_aix.go. At the end of the day the platform-specific code is just a global func(b []byte) error, so simplified the package around that assumption. This also includes the following change, which used to be a separate CL. crypto/rand: improve getrandom batching and retry logic The previous logic assumed getrandom never returned short, and then applied stricter-than-necessary batch size limits, presumably to avoid short returns. This was still not sufficient because above 256 bytes getrandom(2) can be interrupted by a signal and return short *or* it can simply return EINTR if the pool is not initialized (regardless of buffer size). https://man.archlinux.org/man/getrandom.2#Interruption_by_a_signal_handler Whether this ever failed in practice is unknown: it would have been masked by the /dev/urandom fallback before. Instead, we apply buffer size limits only where necessary (really, only Solaris in practice and FreeBSD in theory) and then handle gracefully short returns and EINTR. Change-Id: I8677b457aab68a8fb6137a3b43538efc62eb7c93 It turns out that we now know that large getrandom calls *did* fail in practice, falling back on /dev/urandom, because when we removed the fallback TestBidiStreamReverseProxy with its 4KiB read started failing. https://cr-buildbucket.appspot.com/build/8740779846954406033 For #66821 Change-Id: Iaca62997604f326501a51401cdc2659c2790ff22 Reviewed-on: https://go-review.googlesource.com/c/go/+/602495 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-02src/net/http: remove ServeMux.patternsJonathan Amsterdam
Remove an unexported field from ServeMux that was there only to support some Google-internal packages. It is no longer needed. Change-Id: I6a4d542c6c016f5a9f3d24d0c73f6ddd44c9562e Reviewed-on: https://go-review.googlesource.com/c/go/+/616355 Reviewed-by: Chressie Himpel <chressie@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-10-02all: use slices.Sorted(maps.Keys(m))Tobias Klauser
Use slices.Sorted(maps.Keys(m)) to get a sorted slices of the keys in a map. Do not change packages built during bootstrap, as the bootstrap compiler (currently 1.22.6) does not have the required maps and slices functions. Change-Id: Ie35565d241fa14aca56b730a69af010127b659ab Reviewed-on: https://go-review.googlesource.com/c/go/+/617356 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-09-26net/http: use sync.OnceFunc, sync.OnceValueapocelipes
Use sync.OnceFunc and sync.OnceValue to simplify the code. Change-Id: Ie47e0444c2b9d3260f6ef94cdc6ee8ee5bcf9f71 GitHub-Last-Rev: 520afbec2a392d73dfd9697035804be7c7cc8b77 GitHub-Pull-Request: golang/go#69634 Reviewed-on: https://go-review.googlesource.com/c/go/+/616037 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
2024-09-13net/http: make use of maps.CopyJes Cok
Change-Id: If8e02760fe1fb095ecebc306fd98662a51a1f66f GitHub-Last-Rev: 7b8099f1fed04271c121cdde1c3abd8822955368 GitHub-Pull-Request: golang/go#69426 Reviewed-on: https://go-review.googlesource.com/c/go/+/612736 Reviewed-by: Tim King <taking@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-09-13internal/testenv: add MustHaveSource, rm HasSrcKir Kolyshkin
All the users of HasSrc call t.Skip anyway, so let's move it to testenv. Fix go/build to use MustHaveSource rather than MustHaveGoBuild where appropriate. Change-Id: I052bf96fd5a5780c1930da5b3a52b7a8dbebea46 Reviewed-on: https://go-review.googlesource.com/c/go/+/612057 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tim King <taking@google.com> Auto-Submit: Tim King <taking@google.com>
2024-09-10net/http: make use of maps.Clone for Transport.{Clone, RegisterProtocol}Jes Cok
Not a big deal, maybe it's a bit clearer that it's cloning a map. Change-Id: I7c85382a01df97d1f58109b2483061e6decdf03a GitHub-Last-Rev: 7a88af7f56ab7ad017081187e226e901752fa8bc GitHub-Pull-Request: golang/go#69357 Reviewed-on: https://go-review.googlesource.com/c/go/+/612015 Auto-Submit: Damien Neil <dneil@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>
2024-09-03all: omit unnecessary 0 in slice expressionnlwkobe30
All changes are related to the code, except for the comments in src/regexp/syntax/parse.go and src/slices/slices.go. Change-Id: I73c5d3c54099749b62210aa7f3182c5eb84bb6a6 GitHub-Last-Rev: 794aa9b0539811d00e1cd42be1e8d9fe9afe0281 GitHub-Pull-Request: golang/go#69170 Reviewed-on: https://go-review.googlesource.com/c/go/+/609678 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-08-29net/http: add HTTP2ConfigDamien Neil
Add a field to Server and Transport containing HTTP/2 configuration parameters. This field will have no effect until golang.org/x/net/http2 is updated to make use of it, and h2_bundle.go is updated with the new http2 package. For #67813 Change-Id: I81d7f8e9ddea78f9666383983aec43e3884c13ed Reviewed-on: https://go-review.googlesource.com/c/go/+/602175 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-08-27net/http: simplify http.Request.CloneJes Cok
By using maps.Clone and omitting nil checks when calling http.Header.Clone. I'm not using slices.Clone because the result of slices.Clone may have additional unused capacity. Change-Id: I4aed0fea218404c7270e35324e6bd62d855296c7 GitHub-Last-Rev: 9fd5dd59078c69c9a8057f6fc4a90f7c6aac893b GitHub-Pull-Request: golang/go#69070 Reviewed-on: https://go-review.googlesource.com/c/go/+/608295 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-14net/http/httputil: close res body in testguoguangwu
Change-Id: Ic57c93a8d8413fe4985bc430255b6db90e11b70c GitHub-Last-Rev: 25db6644c6cd3ae532796b18f8978f84a51376af GitHub-Pull-Request: golang/go#68397 Reviewed-on: https://go-review.googlesource.com/c/go/+/597936 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2024-08-13net/http: rename server receiver for consistencywineandchord
"receiver name `srv` should be consistent with the previous receiver name `s` for Server" according to go-lint. Change-Id: I3071ae30b7c1375999e5a599a0eee7b88494f17e GitHub-Last-Rev: 093c7679b1919f364ed542904203d22ed2048313 GitHub-Pull-Request: golang/go#65787 Reviewed-on: https://go-review.googlesource.com/c/go/+/565175 Auto-Submit: 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: Damien Neil <dneil@google.com>
2024-07-30net/http: match os.File.Readdir behavior in DotFileHidingSean Liao
Fixes #67697 Change-Id: I26b26262d885d0704851c08c79e7b2b4872b65ad Reviewed-on: https://go-review.googlesource.com/c/go/+/598075 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-07-29net/http: don't write HEAD response body in ResponseWriter.ReadFromDamien Neil
Responses to HEAD requests don't have a body. The ResponseWriter automatically discards writes to the response body when responding to a HEAD request. ResponseWriter.ReadFrom was failing to discard writes under some circumstances; fix it to do so. Fixes #68609 Change-Id: I912f6b2b2a535df28ae37b875fcf15b10da1af2b Reviewed-on: https://go-review.googlesource.com/c/go/+/601475 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Auto-Submit: 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>
2024-07-29cmd,log,net,runtime: simplify string prefix and suffix processingapocelipes
Use the TrimPrefix, TrimSuffix and CutPrefix to simplify the code. Change-Id: I3e2b271ec0d3f9ce664b830e2b0c21ab47337ed0 GitHub-Last-Rev: 4bd1577d2496173800d609da75b08f6de177aba9 GitHub-Pull-Request: golang/go#68629 Reviewed-on: https://go-review.googlesource.com/c/go/+/601675 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-07-29net/http: don't write body for HEAD responses in Response.WriteDamien Neil
Fixes #62015 Change-Id: I88c5427f85e740d5b956942bb1c2727dac2935ea Reviewed-on: https://go-review.googlesource.com/c/go/+/601238 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-25net: use slices and maps to clean up testsapocelipes
Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is much faster. Change-Id: I54600fb63a56460c11d3d5af9072da585e31b1a2 GitHub-Last-Rev: 08c1445ad5be94d071e8ceb4b060b8f4ab0d77ba GitHub-Pull-Request: golang/go#67606 Reviewed-on: https://go-review.googlesource.com/c/go/+/587816 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-07-23all: update vendored dependenciesDmitri Shuralyov
The Go 1.24 development tree has opened. This is a time to 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 Change-Id: I5a012af9f041f79ab4d5b30569a154e0c2d1617e Reviewed-on: https://go-review.googlesource.com/c/go/+/600535 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-07-15net/http: document io.Seeker requirement for fs.FS argumentsSean Liao
Using the same wording as http.FS, even though it's not strictly required if a content type can be determined by file extension. Fixes #66877 Updates #44553 Change-Id: I7b70c10909bdd289a57d1998a565262b8aaf2dd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/597977 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: 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>
2024-06-28net/http: avoid appending an existing trailing slash to path againJes Cok
This CL is similar to CL 562557, and it takes over CL 594175. While here, unrelatedly remove mapKeys function, use slices.Sorted(maps.Keys(ms)) to simplify code. Fixes #67657 Change-Id: Id8b99216f87a6dcfd6d5fa61407b515324c79112 Reviewed-on: https://go-review.googlesource.com/c/go/+/594737 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Joedian Reid <joedian@google.com>
2024-06-24net/http: document that Request.Clone does not deep copy BodyDamien Neil
Fixes #36095 Change-Id: I94ae014b0ee45b4aeb38cb247e42cfc13f663ded Reviewed-on: https://go-review.googlesource.com/c/go/+/593175 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-06-18net/http: keep Content-Encoding in Error, add GODEBUG for ServeContentDamien Neil
This reverts the changes to Error from CL 571995, and adds a GODEBUG controlling the changes to ServeContent/ServeFile/ServeFS. The change to remove the Content-Encoding header when serving an error breaks middleware which sets Content-Encoding: gzip and wraps a ResponseWriter in one which compresses the response body. This middleware already breaks when ServeContent handles a Range request. Correct uses of ServeContent which serve pre-compressed content with a Content-Encoding: gzip header break if we don't remove that header when serving errors. Therefore, we keep the change to ServeContent/ ServeFile/ServeFS, but we add the ability to disable the new behavior by setting GODEBUG=httpservecontentkeepheaders=1. We revert the change to Error, because users who don't want to include a Content-Encoding header in errors can simply remove the header themselves, or not add it in the first place. Fixes #66343 Change-Id: Ic19a24b73624a5ac1a258ed7a8fe7d9bf86c6a38 Reviewed-on: https://go-review.googlesource.com/c/go/+/593157 Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-06-07net/http: check GetConfigForClient in server.ServeTLSChance Zibolski
Just like for tls.Config.GetCertificate the http.Server.ServeTLS method should be checking tls.Config.GetConfigForClient before trying top open the specified certFile/keyFile. This was previously fixed for crypto/tls when using tls.Listen in CL205059, but the same change for net/http was missed. I've added a comment src/crypto/tls/tls.go in the relevant section in the hope that any future changes of a similar nature consider will consider updating net/http as needed as well. Change-Id: I312303bc497d92aa2f4627fe2620c70779cbcc99 GitHub-Last-Rev: 6ed29a900816a13690a9f3e26476d9bc1055a6f7 GitHub-Pull-Request: golang/go#66795 Reviewed-on: https://go-review.googlesource.com/c/go/+/578396 Reviewed-by: 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> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-06-06net/http: send body or close connection on expect-100-continue requestsDamien Neil
When sending a request with an "Expect: 100-continue" header, we must send the request body before sending any further requests on the connection. When receiving a non-1xx response to an "Expect: 100-continue" request, send the request body if the connection isn't being closed after processing the response. In other words, if either the request or response contains a "Connection: close" header, then skip sending the request body (because the connection will not be used for further requests), but otherwise send it. Correct a comment on the server-side Expect: 100-continue handling that implied sending the request body is optional. It isn't. For #67555 Change-Id: Ia2f12091bee697771087f32ac347509ec5922d54 Reviewed-on: https://go-review.googlesource.com/c/go/+/591255 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-06-05net/http: use default HTTP/2 frame schedulerDamien Neil
Use the default frame scheduler (currently round-robin) rather than overriding the default with the priority scheduler. The priority scheduler is slow, known buggy, and implements a deprecated stream prioritization mechanism. The default changed in x/net about a year ago, but we missed that net/http is overriding that default. Fixes #67706 Change-Id: I6d76dd0cc8c55eb5dec5cd7d25a5084877e8e8d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/590796 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>
2024-06-04all: update vendored dependenciesMichael Anthony Knyszek
The Go 1.23 code freeze has recently started. This is a time to 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 Change-Id: I9162f547c148809d6fb1e4157f6f504634cef3b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/589935 Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-29all: document legacy //go:linkname for final round of modulesRuss Cox
Add linknames for most modules with ≥50 dependents. Add linknames for a few other modules that we know are important but are below 50. Remove linknames from badlinkname.go that do not merit inclusion (very small number of dependents). We can add them back later if the need arises. Fixes #67401. (For now.) Change-Id: I1e49fec0292265256044d64b1841d366c4106002 Reviewed-on: https://go-review.googlesource.com/c/go/+/587756 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Bypass: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-05-23std: fix calls to Printf(s) with non-constant sAlan Donovan
In all cases the intent was not to interpret s as a format string. In one case (go/types), this was a latent bug in production. (These were uncovered by a new check in vet's printf analyzer.) Updates #60529 Change-Id: I3e17af7e589be9aec1580783a1b1011c52ec494b Reviewed-on: https://go-review.googlesource.com/c/go/+/587855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Russ Cox <rsc@golang.org>
2024-05-23net/http: remove TestTransportDialCancelRaceDamien Neil
This test was added to cover a specific race condition in request cancellation, applying only to the deprecated Transport.CancelRequest cancellation path. The test assumes that canceling a request at the moment persistConn.RoundTrip begins guarantees that it will be canceled before being sent. This does not apply to the newer forms of canceling a request: Request.Cancel and context-based cancellation both send the cancel signal on a channel, and do not check for cancellation before sending a request. A recent refactoring unified the implementation of cancellation, so the Transport.CancelRequest path now translates into context-based cancellation internally. This makes this test flaky, since sometimes the request completes before we read from the context's done channel. Drop the test entirely. It's verifying the fix for a bug in a code path which no longer exists, and the property that it's testing for (canceling a request at a very specific point in the internal request flow) is not interesting. Fixes #67533 Change-Id: I8d71540f1b44a64e0621d31a1c545c9351ae897c Reviewed-on: https://go-review.googlesource.com/c/go/+/587935 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>