aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
AgeCommit message (Collapse)Author
2024-05-23all: document legacy //go:linkname for modules with ≥200 dependentsRuss Cox
Ignored these linknames which have not worked for a while: github.com/xtls/xray-core: context.newCancelCtx removed in CL 463999 (Feb 2023) github.com/u-root/u-root: funcPC removed in CL 513837 (Jul 2023) tinygo.org/x/drivers: net.useNetdev never existed For #67401. Change-Id: I9293f4ef197bb5552b431de8939fa94988a060ce Reviewed-on: https://go-review.googlesource.com/c/go/+/587576 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-23all: document legacy //go:linkname for modules with ≥500 dependentsRuss Cox
For #67401. Change-Id: I7dd28c3b01a1a647f84929d15412aa43ab0089ee Reviewed-on: https://go-review.googlesource.com/c/go/+/587575 Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-23all: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 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> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-22crypto/tls: disable 3-DES by defaultFilippo Valsorda
Fixes #66214 Change-Id: Iba8006a17fc7cd33c7485ab1a1ef8f56531c0ed1 Reviewed-on: https://go-review.googlesource.com/c/go/+/587295 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Filippo Valsorda <filippo@golang.org>
2024-05-22net/http: add partitioned attribute to cookie typeislishude
Fixes #62490 Change-Id: Ibe7df96f50275c9321462e994a962031cb1f3018 GitHub-Last-Rev: 7df8738b804c3d82460eec1fc4acd7c6ad733fe1 GitHub-Pull-Request: golang/go#62499 Reviewed-on: https://go-review.googlesource.com/c/go/+/526435 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> Reviewed-by: Théo Dury <tdury2@gmail.com>
2024-05-21net/http: disable flaky 100-continue testsDamien Neil
Disable three 100-continue tests that aren't exercising the intended behavior because they don't set ExpectContinueTimeout. The tests are flaky right now; setting ExpectContinueTimeout makes them consistently fail. Set ExpectContinueTimeout and t.Skip the tests for now. Fixes #67382 For #67555 Change-Id: I459a19a927e14af03881e89c73d20c93cf0da43e Reviewed-on: https://go-review.googlesource.com/c/go/+/587155 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> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-05-17all: add push linknames to allow legacy pull linknamesCherry Mui
CL 585358 adds restrictions to disallow pull-only linknames (currently off by default). Currently, there are quite some pull- only linknames in user code in the wild. In order not to break those, we add push linknames to allow them to be pulled. This CL includes linknames found in a large code corpus (thanks Matthew Dempsky and Michael Pratt for the analysis!), that are not currently linknamed. Updates #67401. Change-Id: I32f5fc0c7a6abbd7a11359a025cfa2bf458fe767 Reviewed-on: https://go-review.googlesource.com/c/go/+/586137 Reviewed-by: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-17net/http: return correct error when reading from a canceled request bodyDamien Neil
CL 546676 inadvertently changed the error returned when reading from the body of a canceled request. Fix it. Rework various request cancelation tests to exercise all three ways of canceling a request. Fixes #67439 Change-Id: I14ecaf8bff9452eca4a05df923d57d768127a90c Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race Reviewed-on: https://go-review.googlesource.com/c/go/+/586315 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-16net/http: add Pattern field in Request to return matched pattern infoChen.Zhidong
Fixes #66405 Change-Id: Icd80944b6ca081aa7addd4fb85d2b3c29b6c9542 GitHub-Last-Rev: c6e32742c4b733230c82627571b423de45997c24 GitHub-Pull-Request: golang/go#66618 Reviewed-on: https://go-review.googlesource.com/c/go/+/574997 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-16net/http: simplify HTTP/1 request cancelationDamien Neil
HTTP requests have three separate user cancelation signals: Transport.CancelRequest Request.Cancel Request.Context() In addition, a request can be canceled due to errors. The Transport keeps a map of all in-flight requests, with an associated func to run if CancelRequest is called. Confusingly, this func is *not* run if Request.Cancel is closed or the request context expires. The map of in-flight requests is also used to communicate between roundTrip and readLoop. In particular, if readLoop reads a response immediately followed by an EOF, it may send racing signals to roundTrip: The connection has closed, but also there is a response available. This race is resolved by readLoop communicating through the request map that this request has successfully completed. This CL refactors all of this. In-flight requests now have a context which is canceled when any of the above cancelation events occurs. The map of requests to cancel funcs remains, but is used strictly for implementing Transport.CancelRequest. It is not used to communicate information about the state of a request. Change-Id: Ie157edc0ce35f719866a0a2cb0e70514fd119ff8 Reviewed-on: https://go-review.googlesource.com/c/go/+/546676 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-05-15net/http, reflect: rename Test function namesJes Cok
To be consistent with other tests. Change-Id: Ibea1d3bf57a295f024e05173d17112ce46a4f0bc Reviewed-on: https://go-review.googlesource.com/c/go/+/585895 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> Auto-Submit: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-05-14net/http: avoid panic when writing 100-continue after handler doneDamien Neil
When a request contains an "Expect: 100-continue" header, the first read from the request body causes the server to write a 100-continue status. This write caused a panic when performed after the server handler has exited. Disable the write when cleaning up after a handler exits. This also fixes a bug where an implicit 100-continue could be sent after a call to WriteHeader has sent a non-1xx header. This change drops tracking of whether we've written a 100-continue or not in response.wroteContinue. This tracking was used to determine whether we should consume the remaining request body in chunkWriter.writeHeader, but the discard-the-body path was only taken when the body was already consumed. (If the body is not consumed, we set closeAfterReply, and we don't consume the remaining body when closeAfterReply is set. If the body is consumed, then we may attempt to discard the remaining body, but there is obviously no body remaining.) Fixes #53808 Change-Id: I3542df26ad6cdfe93b50a45ae2d6e7ef031e46fa Reviewed-on: https://go-review.googlesource.com/c/go/+/585395 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-05-10net/http/httptest: add comment to Server.Client() about Server.URLAlireza Ghasemi
Updates #30774. Change-Id: I9564f955b15c701bee27aa9fbf3972de8fdb55e4 GitHub-Last-Rev: 50bd6bd54ec4195ed9e09a4a2d69e386bf55b21f GitHub-Pull-Request: golang/go#67037 Reviewed-on: https://go-review.googlesource.com/c/go/+/581777 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-09net/http: remove misleading response headers on errorRuss Cox
This is a reapply of CL 544019 and CL 569815, but with less aggressive semantics as discussed in proposal #66343. Error deletes Content-Encoding, since it is writing the response and any preset encoding may not be correct. On the error-serving path in ServeContent/ServeFile/ServeFS, these functions delete additional headers: Etag, Last-Modified, and Cache-Control. The caller may have set these intending them for the success response, and they may well not be correct for error responses. Fixes #50905. Fixes #66343. Change-Id: I873d33edde1805990ca16d85ea8d7735b7448626 Reviewed-on: https://go-review.googlesource.com/c/go/+/571995 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-30net/http: represent multi wildcards properlyJonathan Amsterdam
The routing tree used for matching ServeMux patterns used the key "*" to hold a child node for a multi-segment wildcard. The problem is that "*" is a valid path segment, which confused the matching algorithm: it would fetch the multi wildcard child when looking for the literal child for "*". Eschew clever encodings. Use a separate field in the node to represent the multi wildcard child. Fixes #67067. Change-Id: I300ca08b8628f5367626cf41979f6c238ed8c831 Reviewed-on: https://go-review.googlesource.com/c/go/+/582115 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-04-30http: fix some comments typo in server.goThe Backend Grip
Change-Id: I826412175876a84ab978aba9418be28593484fba GitHub-Last-Rev: d35753c7e027ce4ca1fe63d96985de9e90bf813b GitHub-Pull-Request: golang/go#67112 Reviewed-on: https://go-review.googlesource.com/c/go/+/582435 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-25net/http: improve continue statements for testsJes Cok
Change-Id: I302368c17fbb6983bd14ab72784076e548ed8829 Reviewed-on: https://go-review.googlesource.com/c/go/+/581475 Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-23all: fix some typos in commentsracequite
This change fixes some typographic errors that I found in various packages. Change-Id: Ie2d0316f0137d6521496d389a9777659ae22128b GitHub-Last-Rev: 0307b03d50f664a00a4afa5afa08a35efb7f3045 GitHub-Pull-Request: golang/go#66917 Reviewed-on: https://go-review.googlesource.com/c/go/+/580077 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Commit-Queue: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-22net/http: correct error messages for TestParseSetCookieJes Cok
This change fixes typos in error messages, while here, also improves 'line' strings to indicate the errEqualNotFoundInCookie error. Change-Id: I0ce6115c605844d2d86f337f208fd3b2d3774674 Reviewed-on: https://go-review.googlesource.com/c/go/+/579799 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Joedian Reid <joedian@google.com> Auto-Submit: Damien Neil <dneil@google.com>
2024-04-19net/http: add field Cookie.Quoted boolNuno Gonçalves
The current implementation of the http package strips double quotes from the cookie-value during parsing, resulting in the serialized cookie not including them. This patch addresses this limitation by introducing a new field to track whether the original value was enclosed in quotes. Additionally, the internal representation of a cookie in the cookiejar package has been adjusted to align with the new representation. The syntax of cookies is outlined in RFC 6265 Section 4.1.1: https://datatracker.ietf.org/doc/html/rfc6265\#section-4.1.1 Fixes #46443 Change-Id: Iac12a56397d77a6060a75757ab0daeacc60457f3 GitHub-Last-Rev: a76440e741440cddaa05944b6828a14a32b5a44a GitHub-Pull-Request: golang/go#66752 Reviewed-on: https://go-review.googlesource.com/c/go/+/577755 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-04-18net/http: add case for TestParseSetCookieJes Cok
Updates #66008 Change-Id: Idd36a7f0b4128adfd0a3d7fe76eb6c2cea4306a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/579795 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2024-04-18net/http: add comments that servemux121.go should remain frozenapocelipes
Change-Id: I6d1e02ffd07dbb722669abb2e72784dcb2bfffd0 GitHub-Last-Rev: 55a82f724a32237be059ae0696cf023db414f1d0 GitHub-Pull-Request: golang/go#66848 Reviewed-on: https://go-review.googlesource.com/c/go/+/579118 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-04-17net/http: don't cancel Dials when requests are canceledDamien Neil
Currently, when a Transport creates a new connection for a request, it uses the request's Context to make the Dial. If a request times out or is canceled before a Dial completes, the Dial is canceled. Change this so that the lifetime of a Dial call is not bound by the request that originated it. This change avoids a scenario where a Transport can start and then cancel many Dial calls in rapid succession: - Request starts a Dial. - A previous request completes, making its connection available. - The new request uses the now-idle connection, and completes. - The request Context is canceled, and the Dial is aborted. Fixes #59017 Change-Id: I996ffabc56d3b1b43129cbfd9b3e9ea7d53d263c Reviewed-on: https://go-review.googlesource.com/c/go/+/576555 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-04-17net/http: add ParseCookie, ParseSetCookieJes Cok
Fixes #66008 Change-Id: I64acb7da47a03bdef955f394682004906245a18b Reviewed-on: https://go-review.googlesource.com/c/go/+/578275 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-04-12net/http: fix debugRoundTrip log typoguangwu
Change-Id: I449fcb008fa4c1f51de0bef9f016907d8b99da67 GitHub-Last-Rev: b2e84f1a8a96199e1f9e4ae548225273e2ec94c0 GitHub-Pull-Request: golang/go#66772 Reviewed-on: https://go-review.googlesource.com/c/go/+/578135 Reviewed-by: Carlos Amedee <carlos@golang.org> 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>
2024-04-08all: update vendored golang.org/x/netDmitri Shuralyov
Pull in CL 576895: ec05fdcd http2: don't retry the first request on a connection on GOAWAY error For #66668. Fixes #60636. Change-Id: I9903607e3d432a5db0325da82eb7f4b378fbddde Reviewed-on: https://go-review.googlesource.com/c/go/+/576976 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-08net/http: update HandlerWritesTooMuch test to allow different h1/h2 behaviorDamien Neil
Rather than requiring that HTTP/1 and HTTP/2 servers behave identically when a misbehaving handler writes too many bytes, check only that both behave reasonably. In particular, allow the handler to defer detection of a write overrun until flush time, and permit the HTTP/2 handler to reset the stream rather than requring it to return a truncated body as HTTP/1 must. For #56019 Change-Id: I0838e550c4fc202dcbb8bf39ce0fa4a367ca7e71 Reviewed-on: https://go-review.googlesource.com/c/go/+/577415 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
2024-04-05all: update vendored golang.org/x/netDmitri Shuralyov
Pull in CL 576756: b67a0f05 http2: send correct LastStreamID in stream-caused GOAWAY It comes with newer x/crypto and x/sys requirements via CL 576516. For #65051. Fixes #66668. Change-Id: Ib6df49b779ff5ea56966ae3de443e87ac7f4ec4f Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/576679 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> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-05all: update vendored golang.org/x/net to v0.23.0Dmitri Shuralyov
Pull in CL 576155: ba872109 http2: close connections when receiving too many headers Fixes CVE-2023-45288. Fixes #65051. Change-Id: I3f4e3d565189b4ed552935fe1d96f94ebac86d48 Reviewed-on: https://go-review.googlesource.com/c/go/+/576295 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-04-03net/http: speed up go testFelix Geisendörfer
Optimize the execution speed of go test ./net/http from ~38s to ~28s. This is achieved by shortening the sleep interval utilized for identifying goroutine leaks. This optimization is motivated by noticing significant periods of inactivity in the -trace output. Even after applying this CL, many Off-CPU wait periods seem to remain: $ go test ./net/http ok net/http 27.744s real 0m28.204s user 0m4.991s sys 0m1.797s Change-Id: I6108ebbb715c33900f1506d810c0a8f8ed674d35 Reviewed-on: https://go-review.googlesource.com/c/go/+/575975 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> Auto-Submit: Damien Neil <dneil@google.com>
2024-03-29net/http: correct doc for ServeFileFSJes Cok
The documentation of ServeFileFS was partly copied from ServeFile in CL 513956, however it's not exact. This CL fixes some typos, also removes obsolete comment for name param. For consistency, also adds godoc link for ServeFile and ServeContent. Fixes #66578 Change-Id: I87147d72c533d46284f06ef20b37fdafa8706710 Reviewed-on: https://go-review.googlesource.com/c/go/+/575016 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2024-03-26all: fix a large number of commentscui fliter
Partial typo corrections, following https://go.dev/wiki/Spelling Change-Id: I2357906ff2ea04305c6357418e4e9556e20375d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/573776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-26net/http: fix typo in log messageDamien Neil
Change-Id: I399c65b44706cf5407099e867de27b3acdaf4825 Reviewed-on: https://go-review.googlesource.com/c/go/+/574235 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> 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>
2024-03-26net/http: panic early in do when Client is nilKevin Burke
Callers who invoke `*http.Client.Do` with a nil *Client will now panic at the top of c.Do, instead of panicking when `deadline` attempts to read `c.Timeout`. Errors inside of net/http can be difficult to track down because the caller is often invoking the standard library code via an SDK. This can mean that there are many places to check when code panics, and raises the importance of being clear about error messages. If nil receiver calls panic during the `deadline()` call, callers may confuse the error with a more common timeout or deadline misconfiguration, which may lead a caller who passed a nil receiver (the author, for example) down the wrong rabbit hole, or cause them to suspect their timeout/deadline logic. It is less common to configure client.Jar, so the probability of detecting the actual problem, given the underlying error cause, is higher. Fixes #53521. Change-Id: If102d17bed56fdd950da6e87762166fd29724654 Reviewed-on: https://go-review.googlesource.com/c/go/+/413975 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-25net/http: also log TLS errors which look like HTTP sent to an HTTPS portDamien Neil
We log TLS handshake errors in general, but currently do not log errors when the first TLS record looks like an attempt to send HTTP to an HTTPS port. There doesn't seem to be any principled reason to log the one and not the other, so just log all TLS handshake errors. Fixes #66501 Change-Id: I5d78a754d054c220be935513448515721fa387a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/573979 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-25net/http: eliminate the needless idle timeout for TestServerNoReadTimeoutAndy Pan
Change-Id: I1339749bfeac99848beca780cebb9c87564da656 Reviewed-on: https://go-review.googlesource.com/c/go/+/573335 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-25net/http: update bundled x/net/http2Andy Pan
Keep ReadTimeout, ReadHeaderTimeout, IdleTimeout and WriteTimeout in sync Change-Id: I32b43884c0078eca86f20ec363f1d702ba298d1c Reviewed-on: https://go-review.googlesource.com/c/go/+/573315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com>
2024-03-22net/http: ensure server handler is done in TestServerNoWriteTimeoutDamien Neil
Surprisingly, newClientServerTest doesn't ensure that server handlers are done in its t.Cleanup function. This test's handler can outlive the test and attempt to log after the test has completed, causing race detector failures. Add an explicit call to Server.Shutdown to ensure the handler has completed. We should also probably add a Shutdown to clientServerTest.close, but that's a larger change; this fixes the immediate problem. Change-Id: Ibe81b4b382c9c8a920b0ff5f76dea6afe69b10f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/573895 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-03-21net/http: use slices to simplify the codeapocelipes
"strSliceContains" is replaced by "slices.Contains". Replace "sort.Strings" with "slices.Sort" since it becomes a wrapper of "slices.Sort" from Go 1.22. "headerSorter" no longer has to implement "sort.Interface". We use "slice.SortFunc" to sort kvs. Change-Id: Ic29b4c3db147c16079575eca7ad6ff6c0f581188 GitHub-Last-Rev: 78221d5aa223a259a89860b672f39a34897df253 GitHub-Pull-Request: golang/go#66440 Reviewed-on: https://go-review.googlesource.com/c/go/+/573275 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-21src/go.mod, net/http: update bundled+latest golang.org/x/netEmmanuel T Odeke
Updates x/net/http2 to git rev 89f602b7bbf237abe0467031a18b42fc742ced08 http2: validate client/outgoing trailers https://golang.org/cl/572655 (updates #64766) and also updates the vendored version of golang.org/x/net per: $ go get golang.org/x/net@89f602b7bb $ go mod tidy $ go mod vendor $ go generate -run bundle std Change-Id: Ibd0e819d9125e72665bafec53ba626e257b594a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/572676 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2024-03-21net/http: add tests with zero and negative read/write timeoutsAndy Pan
Change-Id: I38ebd280c200b30692eb35640327034a5e898bd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/570376 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-21net/http: improve error reporting in TestCancelRequestWhenSharingConnectionDamien Neil
Ensure that errors are reported if an HTTP request unexpectedly fails. For #56587 Change-Id: I1adfb4fedc24d4177caf54e34c5033267e32caa6 Reviewed-on: https://go-review.googlesource.com/c/go/+/486075 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-20net/http: add Request.CookiesNamedTimo Furrer
Implements a new method http.Request.CookiesName, that allows retrieving all cookies that match the given name. Fixes #61472 Change-Id: I405d8771b4195af9ff6b4dfde3cfcd316c23b70c GitHub-Last-Rev: 6ad0094995b45648ebbcd18626f07bb879a3f7cf GitHub-Pull-Request: golang/go#61473 Reviewed-on: https://go-review.googlesource.com/c/go/+/511516 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2024-03-20net/http: validate outgoing/client request trailersEmmanuel T Odeke
This change validates outbound client request trailers just like we do for headers. This helps prevent header injection or other sorts of smuggling from easily being performed using the standard HTTP client. Fixes #64766 Change-Id: Idb34df876a0c308b1f57e9ae2695b118ac6bcc2d Reviewed-on: https://go-review.googlesource.com/c/go/+/572615 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> 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> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-19net/http: update bundled x/net/http2Andy Pan
For #65785 #65927 Change-Id: I21791d4e22ae3039144f6b105ac439877f8b01bf Reviewed-on: https://go-review.googlesource.com/c/go/+/569819 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-18net/http: fix request canceler leak on connection closeAlexander Yastrebov
writeLoop goroutine closes persistConn closech in case of request body write error which in turn finishes readLoop without removing request canceler. Fixes #61708 Change-Id: Ib7c832a91b49bc7888a35a4fd2bd692236c04f86 GitHub-Last-Rev: b74b9055e87121d4dc5d97a3f3ef1afe545bc92d GitHub-Pull-Request: golang/go#62305 Reviewed-on: https://go-review.googlesource.com/c/go/+/523296 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-03-18net/http/httptest: close res.Body in testguoguangwu
Change-Id: Ieec952ebc407ecb1aa20aa03105323505121981c GitHub-Last-Rev: d19724c16dff3ec9c1f23d21054ff8a6ccc3770c GitHub-Pull-Request: golang/go#66263 Reviewed-on: https://go-review.googlesource.com/c/go/+/570915 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-03-18net/http: do not set a deadline when Server.IdleTimeout is negativeAndy Pan
Change-Id: I0d6336e6a21aef14e7229594a335899083fa98b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/570396 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com>
2024-03-15net/http: revert header changes in ErrorRuss Cox
This reverts CL 544019 and CL 569815, because they break a variety of tests inside Google that do not expect the Cache-Control header to be set to no-cache. A followup CL will add this functionality back after a proposal. For #50905. Change-Id: Ie377bfb72ce2c77d11bf31f9617ab6db342a408a Reviewed-on: https://go-review.googlesource.com/c/go/+/571975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-03-14Revert "net/http: remove superfluous newline on redirects"Russ Cox
This reverts commit 2b58355ef624239dbe32185dc8dfc9d1074615c6. Reason for revert: This breaks tons of tests for no real reason. Change-Id: I89773f48cf983c0b6346e46c37a0ebbe2620e3b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/571675 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>