aboutsummaryrefslogtreecommitdiff
path: root/src/net
AgeCommit message (Collapse)Author
2021-12-09[release-branch.go1.16] net/http: update bundled golang.org/x/net/http2Filippo Valsorda
Pull in security fix a5309b3 http2: cap the size of the server's canonical header cache Updates #50058 Fixes CVE-2021-44716 Change-Id: Ifdd13f97fce168de5fb4b2e74ef2060d059800b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/370575 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Alex Rakoczy <alex@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-02[release-branch.go1.16] net/http: update bundled golang.org/x/net/http2Michael Anthony Knyszek
Pull in approved backports to golang.org/x/net/http2: 64539c1 http2: don't count aborted streams as active in tests e677a40 ipv6: OpenBSD does not appear to support multicast loopback d8ae719 net/http2: Fix handling of expect continue cc2f99c http2: avoid busy loop when ResponseHeaderTimeout is set 5533dda http2: avoid spurious RoundTrip error when server closes and resets stream 26ec667 http2: close conns after use when req.Close is set By doing: $ go get -d golang.org/x/net@internal-branch.go1.16-vendor go: downloading golang.org/x/net v0.0.0-20211201233224-64539c132272 go get: upgraded golang.org/x/net v0.0.0-20211101194150-d8c3cde3c676 => v0.0.0-20211201233224-64539c132272 $ go mod tidy $ go mod vendor $ go generate -run=bundle std Fixes #49904. Fixes #49623. Fixes #49661. Fixes #49560. Fixes #49908. Fixes #49910. Change-Id: I73261b189f84cf1919a79129ec36a1c187723133 Reviewed-on: https://go-review.googlesource.com/c/go/+/368594 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-12-01[release-branch.go1.16] net/http/httptest: wait for user ConnState hooksDamien Neil
Ensure that user ConnState callbacks have completed before returning from (*httptest.Server).Close. Fixes: #49851 Updates: #37510 Updates: #37505 Updates: #45237 Change-Id: I8fe7baa089fbe4f3836bf6ae9767c7b1270d1331 Reviewed-on: https://go-review.googlesource.com/c/go/+/304829 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit 5cec8b85e5dc75ef21b62efb6bd93f9007385e34) Reviewed-on: https://go-review.googlesource.com/c/go/+/367516 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-12-01[release-branch.go1.16] net/http: do not send Transfer-Encoding: identity in ↵Damien Neil
responses Server handlers may set a "Transfer-Encoding: identity" header on responses to disable chunking, but this header should not be sent on the wire. For #49194. Fixes #49567. Change-Id: I46a9e3b8ff9d93edd7d1c34d264fc309fa322ad5 Reviewed-on: https://go-review.googlesource.com/c/go/+/359176 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit b69b2f63d65609b400b4a40ae01e4a48638f050f) Reviewed-on: https://go-review.googlesource.com/c/go/+/368086 Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-12-01[release-branch.go1.16] net/http: do not cancel request context on response ↵Damien Neil
body read When sending a Request with a non-context deadline, we create a context with a timeout. This context is canceled when closing the response body, and also if a read from the response body returns an error (including io.EOF). Cancelling the context in Response.Body.Read interferes with the HTTP/2 client cleaning up after a request is completed, and is unnecessary: The user should always close the body, the impact from not canceling the context is minor (the context timer leaks until it fires). For #49366. Fixes #49558. Change-Id: Ieaed866116916261d9079f71d8fea7a7b303b8fb Reviewed-on: https://go-review.googlesource.com/c/go/+/361919 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit 76fbd6167364fb98e3ebe946cfc16b5b84d4240e) Reviewed-on: https://go-review.googlesource.com/c/go/+/368084 Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-11-01[release-branch.go1.16] net/http: update bundled golang.org/x/net/http2Dmitri Shuralyov
Pull in approved backports to golang.org/x/net/http2: d8c3cde set ContentLength to -1 for HEAD response with no Content-Length 7b24c0a set Response.ContentLength to 0 when headers end stream c4031f5 don't abort half-closed streams on server connection close 2f744fa on write errors, close ClientConn before returning from RoundTrip 275be3f deflake TestTransportReqBodyAfterResponse_200 d26011a close the Request's Body when aborting a stream e5dd05d return unexpected eof on empty response with non-zero content length 640e170 don't rely on system TCP buffer sizes in TestServer_MaxQueuedControlFrames 198b78c detect write-blocked PING frames 20ed279 avoid race in TestTransportReqBodyAfterResponse_403. d585ef0 avoid clientConnPool panic when NewClientConn fails d06dfc7 avoid extra GetConn trace call 1760f31 refactor request write flow 6e87631 remove PingTimeout from TestTransportPingWhenReading b843c7d fix Transport connection pool TOCTOU max concurrent stream bug ab1d67c shut down idle Transport connections after protocol errors 3741e47 remove check for read-after-close of request bodies 2df4c53 fix race in DATA frame padding refund d7eefc9 avoid blocking while holding ClientConn.mu 78e8d65 fix off-by-one error in client check for max concurrent streams 828651b close request body after early RoundTrip failures 59c0c25 limit client initial MAX_CONCURRENT_STREAMS 524fcad make Transport not reuse conns after a stream protocol error 0fe5f8a accept zero-length block fragments in HEADERS frames 0e5043f close the request body if needed bb4ce86 reduce frameScratchBuffer caching aggressiveness 3112343 also set "http/1.1" ALPN in ConfigureServer 63939f4 switch to ASCII equivalents of string functions 54161af use (*tls.Dialer).DialContext in dialTLS 75b906f discard DATA frames with higher stream IDs during graceful shutdown 1dfe517 rework Ping test to rely less on timing By doing: $ go get -d golang.org/x/net@internal-branch.go1.16-vendor go get: upgraded golang.org/x/net v0.0.0-20210901185431-d2e9a4ea682f => v0.0.0-20211101194150-d8c3cde3c676 $ go mod tidy $ go mod vendor $ go generate -run=bundle std Fixes #49076. Fixes #48822. Fixes #48649. Change-Id: Ie17f327eef2b6e6a9a1ac7635c5c4daef792e893 Reviewed-on: https://go-review.googlesource.com/c/go/+/359774 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-09-02[release-branch.go1.16] all: update golang.org/x/net to pull in CL 346890Damien Neil
For #47691. Change-Id: I6650fdfc78786fc47a54167bf2f9061422bbb343 Reviewed-on: https://go-review.googlesource.com/c/go/+/347031 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-08-04[release-branch.go1.16] net/http: speed up and deflake ↵Damien Neil
TestCancelRequestWhenSharingConnection This test made many requests over the same connection for 10 seconds, trusting that this will exercise the request cancelation race from #41600. Change the test to exhibit the specific race in a targeted fashion with only two requests. Fixes #47535. Updates #41600. Updates #47016. Change-Id: If99c9b9331ff645f6bb67fe9fb79b8aab8784710 Reviewed-on: https://go-review.googlesource.com/c/go/+/339594 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> (cherry picked from commit 6e738868a7a943d7d4fd6bb1963e7f6d78111726) Reviewed-on: https://go-review.googlesource.com/c/go/+/339830
2021-08-02[release-branch.go1.16] net/http/httputil: close incoming ReverseProxy ↵Damien Neil
request body Reading from an incoming request body after the request handler aborts with a panic can cause a panic, becuse http.Server does not (contrary to its documentation) close the request body in this case. Always close the incoming request body in ReverseProxy.ServeHTTP to ensure that any in-flight outgoing requests using the body do not read from it. Fixes #47474 Updates #46866 Fixes CVE-2021-36221 Change-Id: I310df269200ad8732c5d9f1a2b00de68725831df Reviewed-on: https://go-review.googlesource.com/c/go/+/333191 Trust: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> (cherry picked from commit b7a85e0003cedb1b48a1fd3ae5b746ec6330102e) Reviewed-on: https://go-review.googlesource.com/c/go/+/338551 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-07-08[release-branch.go1.16] net: filter bad names from Lookup functions instead ↵Roland Shoemaker
of hard failing Instead of hard failing on a single bad record, filter the bad records and return anything valid. This only applies to the methods which can return multiple records, LookupMX, LookupNS, LookupSRV, and LookupAddr. When bad results are filtered out, also return an error, indicating that this filtering has happened. Updates #46241 Updates #46979 Fixes #46999 Change-Id: I6493e0002beaf89f5a9795333a93605abd30d171 Reviewed-on: https://go-review.googlesource.com/c/go/+/332549 Trust: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> (cherry picked from commit 296ddf2a936a30866303a64d49bc0e3e034730a8) Reviewed-on: https://go-review.googlesource.com/c/go/+/333330 Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-07-08[release-branch.go1.16] net: don't reject null mx recordsRoland Shoemaker
Bypass hostname validity checking when a null mx record is returned as, defined in RFC 7505. Updates #46979 Updates #46999 Change-Id: Ibe683bd6b47333a8ff30909fb2680ec8e10696ef Reviewed-on: https://go-review.googlesource.com/c/go/+/332094 Trust: Roland Shoemaker <roland@golang.org> Trust: Katie Hockman <katie@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> (cherry picked from commit 03761ede028d811dd7d7cf8a2690d4bfa2771d85) Reviewed-on: https://go-review.googlesource.com/c/go/+/332371 Run-TryBot: Katie Hockman <katie@golang.org>
2021-06-29[release-branch.go1.16] net/http: fix ResponseWriter.ReadFrom with short readsDamien Neil
CL 249238 changes ResponseWriter.ReadFrom to probe the source with a single read of sniffLen bytes before writing the response header. If the source returns less than sniffLen bytes without reaching EOF, this can cause Content-Type and Content-Length detection to fail. Fix ResponseWrite.ReadFrom to copy a full sniffLen bytes from the source as a probe. Drop the explicit call to w.WriteHeader; writing the probe will trigger a WriteHeader call. Consistently use io.CopyBuffer; ReadFrom has already acquired a copy buffer, so it may as well use it. Fixes #44984. Updates #44953. Change-Id: Ic49305fb827a2bd7da4764b68d64b797b5157dc0 Reviewed-on: https://go-review.googlesource.com/c/go/+/301449 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit 831f9376d8d730b16fb33dfd775618dffe13ce7a) Reviewed-on: https://go-review.googlesource.com/c/go/+/324971 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-02[release-branch.go1.16] net: don't rely on system hosts in TestCVE202133195Roland Shoemaker
Also don't unnecessarily deref the error return. Updates #46504 Fixes #46530 Change-Id: I22d14ac76776f8988fa0774bdcb5fcd801ce0185 Reviewed-on: https://go-review.googlesource.com/c/go/+/324190 Trust: David Chase <drchase@google.com> Trust: Damien Neil <dneil@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> (cherry picked from commit dd7ba3ba2c860c40be6d70b63d4a678449cae80f) Reviewed-on: https://go-review.googlesource.com/c/go/+/324332 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-02[release-branch.go1.16] net/http: prevent infinite wait during ↵Michael Fraenkel
TestMissingStatusNoPanic If the client request never makes it to the server, the outstanding accept is never broken. Change the test to always close the listening socket when the client request completes. Updates #45358 Change-Id: I744a91dfa11704e7e528163d7669c394e90456dc Reviewed-on: https://go-review.googlesource.com/c/go/+/319275 Trust: Heschi Kreinick <heschi@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> (cherry picked from commit c0a7ecfae775a9d50d338e8123fac32a5d04308c) Reviewed-on: https://go-review.googlesource.com/c/go/+/320190 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-05-28[release-branch.go1.16] net/http/httputil: always remove hop-by-hop headersFilippo Valsorda
Previously, we'd fail to remove the Connection header from a request like this: Connection: Connection: x-header Updates #46313 Fixes #46315 Fixes CVE-2021-33197 Change-Id: Ie3009e926ceecfa86dfa6bcc6fe14ff01086be7d Reviewed-on: https://go-review.googlesource.com/c/go/+/321929 Run-TryBot: Filippo Valsorda <filippo@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Katie Hockman <katie@golang.org> Trust: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> (cherry picked from commit 950fa11c4cb01a145bb07eeb167d90a1846061b3) Reviewed-on: https://go-review.googlesource.com/c/go/+/323090
2021-05-27[release-branch.go1.16] net: verify results from Lookup* are valid domain namesRoland Shoemaker
For the methods LookupCNAME, LookupSRV, LookupMX, LookupNS, and LookupAddr check that the returned domain names are in fact valid DNS names using the existing isDomainName function. Thanks to Philipp Jeitner and Haya Shulman from Fraunhofer SIT for reporting this issue. Updates #46241 Fixes #46357 Fixes CVE-2021-33195 Change-Id: I47a4f58c031cb752f732e88bbdae7f819f0af4f3 Reviewed-on: https://go-review.googlesource.com/c/go/+/323131 Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> (cherry picked from commit cdcd02842da7c004efd023881e3719105209c908) Reviewed-on: https://go-review.googlesource.com/c/go/+/323270
2021-02-16internal/poll: netpollcheckerr before sendfileWei Fu
In net/http package, the ServeContent/ServeFile doesn't check the I/O timeout error from chunkWriter or *net.TCPConn, which means that both HTTP status and headers might be missing when WriteTimeout happens. If the poll.SendFile() doesn't check the *poll.FD state before sending data, the client will only receive the response body with status and report "malformed http response/status code". This patch is to enable netpollcheckerr before sendfile, which should align with normal *poll.FD.Write() and Splice(). Fixes #43822 Change-Id: I32517e3f261bab883a58b577b813ef189214b954 Reviewed-on: https://go-review.googlesource.com/c/go/+/285914 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
2021-01-26net/http/fcgi: remove locking added to prevent a test-only raceHilko Bengen
The race reported in issue #41167 was detected only because the ReadWriter used in test code happened to be a bytes.Buffer whose Read and Write operate (unsafely) on shared state. This is not the case in any realistic scenario where the FastCGI protocol is spoken over sockets or pairs of pipes. Since tests that use nopWriteCloser don't care about any output generate by child.Serve(), we change nopWriteCloser to provide a dummy Write method. Remove the locking added in CL 252417, since it causes a deadlock during write as reported in #43901. The race in tests no longer happens thanks to the aforementioned change to nopWriteCloser. Fixes #43901. Updates #41167. Change-Id: I8cf31088a71253c34056698f8e2ad0bee9fcf6c6 GitHub-Last-Rev: b06d8377fdada075775d79a20577d38a7c471b45 GitHub-Pull-Request: golang/go#43027 Reviewed-on: https://go-review.googlesource.com/c/go/+/275692 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-01-22net/http: fix flaky TestDisableKeepAliveUpgradeDamien Neil
This test hijacks a connection. It was reading from the net.Conn returned by Hijack, not the bufio.ReadWriter, causing flaky failures when a read-ahead byte was held in the read buffer. Fixes #43073. Change-Id: Ic3e7f704fba9635fd851cb3c0c0c74e312b75f6e Reviewed-on: https://go-review.googlesource.com/c/go/+/285596 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Anmol Sethi <nhooyr@gmail.com>
2021-01-06net/http/httputil: fix deadlock in DumpRequestOutSteven Hartland
Fix a deadlock in DumpRequestOut which can occur if the request is cancelled between response being sent and it being processed. Also: * Ensure we don't get a reader leak when an error is reported by the transport before the body is consumed. * Add leaked goroutine retries to avoid false test failures. Fixes #38352 Change-Id: I83710791b2985b997f61fe5b49eadee0bb51bdee Reviewed-on: https://go-review.googlesource.com/c/go/+/232798 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Damien Neil <dneil@google.com>
2020-12-25net/mail: don't use MDT in testIan Lance Taylor
When time.Parse sees a timezone name that matches the local timezone, it uses the local timezone. The tests weren't expecting that, so using MDT broke with TZ=America/Boise (where MDT means Mountain Daylight Time). Just use GMT instead. Fixes #43354 Change-Id: Ida70c8c867e2568b1535d1dfbf1fb0ed9e0e5c1e Reviewed-on: https://go-review.googlesource.com/c/go/+/280072 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2020-12-17crypto/tls: revert "add HandshakeContext method to Conn"Johan Brandhorst
This reverts CL 246338. Reason for revert: waiting for 1.17 release cycle Updates #32406 Change-Id: I074379039041e086c62271d689b4b7f442281663 Reviewed-on: https://go-review.googlesource.com/c/go/+/269697 Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Katie Hockman <katie@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org>
2020-12-16net: close connection in localServer teardownMeng Zhuo
The transponder sets up a deferred close on accepted connections which is fine after the client reads all data. However there are no mutexes nor channels to block the transponder from closing. If the scheduler runs close before the client read, it will cause an EOF failure. Fixes #42720 Change-Id: Ic21b476c5efc9265a80a2c6f8484efdb5af66405 Reviewed-on: https://go-review.googlesource.com/c/go/+/273672 Run-TryBot: Meng Zhuo <mzh@golangcn.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Damien Neil <dneil@google.com>
2020-12-14net/http/pprof: don't treat os.Args as format string in Cmdline handlerBrad Fitzpatrick
Found by @josharian running staticcheck against a fork of this code elsewhere. Change-Id: Ica8bae5df71adde1a71e541dd55b0b81b97b3baf Reviewed-on: https://go-review.googlesource.com/c/go/+/277992 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Josh Bleecher Snyder <josharian@gmail.com>
2020-12-14net/http: attempt deadlock fix in TestDisableKeepAliveUpgradeAnmol Sethi
1. The test now checks the response status code. 2. The transport has been changed to not set "Connection: Close" if DisableKeepAlive is set and the request is a HTTP/1.1 protocol upgrade. Updates #43073 Change-Id: I9977a18b33b8747ef847a8d11bb7b4f2d8053b8c GitHub-Last-Rev: f809cebb139df4f5560a8456973351c95a3dfa97 GitHub-Pull-Request: golang/go#43086 Reviewed-on: https://go-review.googlesource.com/c/go/+/276375 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-12-10std: update golang.org/x/net to 20201209123823-ac852fbbde11Dmitri Shuralyov
Done with: go get -d golang.org/x/net@latest go mod tidy go mod vendor go generate -run bundle std The cmd module was updated as well, but go mod tidy undoes the change because the x/net module doesn't contribute any packages to cmd module. cmd/internal/moddeps.TestDependencyVersionsConsistent is happy with it: // It's ok if there are undetected differences in modules that do not // provide imported packages: we will not have to pull in any backports of // fixes to those modules anyway. Fixes #31192. Updates #42498. Change-Id: If303c9a7aa2ce8c2553fcb1ced7fccc9e6652ad6 Reviewed-on: https://go-review.googlesource.com/c/go/+/277012 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09net/http: add connections back that haven't been canceledMichael Fraenkel
Issue #41600 fixed the issue when a second request canceled a connection while the first request was still in roundTrip. This uncovered a second issue where a request was being canceled (in roundtrip) but the connection was put back into the idle pool for a subsequent request. The fix is the similar except its now in readLoop instead of roundTrip. A persistent connection is only added back if it successfully removed the cancel function; otherwise we know the roundTrip has started cancelRequest. Fixes #42942 Change-Id: Ia56add20880ccd0c1ab812d380d8628e45f6f44c Reviewed-on: https://go-review.googlesource.com/c/go/+/274973 Trust: Dmitri Shuralyov <dmitshur@golang.org> Trust: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2020-12-03mime/multipart: handle ReadForm(math.MaxInt64) betterRuss Cox
Returning an error about integer overflow is needlessly pedantic. The meaning of ReadForm(MaxInt64) is easily understood (accept a lot of data) and can be implemented. Fixes #40430. Change-Id: I8a522033dd9a2f9ad31dd2ad82cf08d553736ab9 Reviewed-on: https://go-review.googlesource.com/c/go/+/275112 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-01net/http: allow upgrading non keepalive connectionsAnmol Sethi
If one was using http.Transport with DisableKeepAlives and trying to upgrade a connection against net/http's Server, the Server would not allow a "Connection: Upgrade" header to be written and instead override it to "Connection: Close" which would break the handshake. This change ensures net/http's Server does not override the connection header for successful protocol switch responses. Fixes #36381. Change-Id: I882aad8539e6c87ff5f37c20e20b3a7fa1a30357 GitHub-Last-Rev: dc0de83201dc26236527b68bd49dffc53dd0389b GitHub-Pull-Request: golang/go#36382 Reviewed-on: https://go-review.googlesource.com/c/go/+/213277 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-12-01net/http: ignore connection closes once done with the connectionMichael Fraenkel
Once the connection is put back into the idle pool, the request should not take any action if the connection is closed. Fixes #41600 Change-Id: I5e4ddcdc03cd44f5197ecfbe324638604961de84 Reviewed-on: https://go-review.googlesource.com/c/go/+/257818 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Damien Neil <dneil@google.com>
2020-11-30net: add note about disabling loopback in ListenMulticastUDP()Andy Pan
Fixes #41752 Change-Id: I83520d2303e5fd2e5f6329f092b40e73c13771a1 Reviewed-on: https://go-review.googlesource.com/c/go/+/271908 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-11-20net, internal/poll: reset value before adding in minor kernel versionIan Lance Taylor
Fixes #42733 Change-Id: I5446aeb5de13cd70212755fb12c9bc484f343c74 Reviewed-on: https://go-review.googlesource.com/c/go/+/271846 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-11-11all: update vendored dependencies for Go 1.16 releaseDmitri Shuralyov
The Go 1.16 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. Those versions have already gone through code review, and now they will undergo additional testing during the upcoming freeze period. If new issues in these dependencies are discovered, we have the freeze period to address them. By the end of the freeze period, we will have confidence that the Go 1.16 release and the dependency versions it has selected are robust. The dependency module versions that are selected in this commit are: github.com/google/pprof v0.0.0-20201007051231-1066cbb265c7 github.com/ianlancetaylor/demangle v0.0.0-20200414190113-039b1ae3a340 golang.org/x/arch v0.0.0-20201008161808-52c3e6f60cff golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 golang.org/x/mod v0.3.1-0.20200828183125-ce943fd02449 golang.org/x/net v0.0.0-20201029221708-28c70e62bb1d golang.org/x/sys v0.0.0-20201110211018-35f3e6cf4a65 golang.org/x/text v0.3.4 golang.org/x/tools v0.0.0-20201110201400-7099162a900a golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 This change was created with a program from CL 256357 patch set 3 (which updates golang.org/x modules only) and the latest bundle tool, but replacing golang.org/x/net version with a slightly older commit golang/net@28c70e62bb1d140c3f2579fb7bb5095134d9cb1e due to #42498: $ updatestd -goroot=$HOME/gotip -branch=master > go version go version devel +ecc3f5112e Thu Nov 5 23:21:33 2020 +0000 darwin/amd64 > go env GOROOT /Users/dmitshur/gotip > go version -m /Users/dmitshur/go/bin/bundle /Users/dmitshur/go/bin/bundle: go1.15.4 path golang.org/x/tools/cmd/bundle mod golang.org/x/tools v0.0.0-20201110201400-7099162a900a h1:5E6TPwSBG74zT8xSrVc8W59K4ch4NFobVTnh2BYzHyU= dep golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= dep golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= updating module cmd in /Users/dmitshur/gotip/src/cmd skipping github.com/chzyer/logex (out of scope, it's not a golang.org/x dependency) skipping github.com/chzyer/readline (out of scope, it's not a golang.org/x dependency) skipping github.com/chzyer/test (out of scope, it's not a golang.org/x dependency) skipping github.com/google/pprof (out of scope, it's not a golang.org/x dependency) skipping github.com/ianlancetaylor/demangle (out of scope, it's not a golang.org/x dependency) skipping github.com/yuin/goldmark (out of scope, it's not a golang.org/x dependency) skipping rsc.io/pdf (out of scope, it's not a golang.org/x dependency) > go mod edit -go=1.16 > go get -d golang.org/x/arch@52c3e6f60cffa0133a3f9b2fc7f6862504a6cba0 golang.org/x/crypto@9e8e0b390897c84cad53ebe9ed2d1d331a5394d9 golang.org/x/mod@ce943fd02449f621243c9ea6e64098e84752b92b golang.org/x/net@28c70e62bb1d140c3f2579fb7bb5095134d9cb1e golang.org/x/sync@67f06af15bc961c363a7260195bcd53487529a21 golang.org/x/sys@35f3e6cf4a65a85bc280e5fe63faed8ac8b25721 golang.org/x/text@22f1617af38ed4cd65b3b96e02bab267e560155c golang.org/x/tools@7099162a900ae8260c5b97cfaf5f374243dfa742 golang.org/x/xerrors@5ec99f83aff198f5fbd629d6c8d8eb38a04218ca > go mod tidy > go mod vendor updating module std in /Users/dmitshur/gotip/src > go mod edit -go=1.16 > go get -d golang.org/x/crypto@9e8e0b390897c84cad53ebe9ed2d1d331a5394d9 golang.org/x/net@28c70e62bb1d140c3f2579fb7bb5095134d9cb1e golang.org/x/sys@35f3e6cf4a65a85bc280e5fe63faed8ac8b25721 golang.org/x/text@22f1617af38ed4cd65b3b96e02bab267e560155c golang.org/x/tools@7099162a900ae8260c5b97cfaf5f374243dfa742 > go mod tidy > go mod vendor updating bundles in /Users/dmitshur/gotip/src > go generate -run=bundle std cmd golang.org/x/net will be updated further later, after #42498 is fixed. github.com/google/pprof and github.com/ianlancetaylor/demangle contribute packages but are out of scope for this generated CL. Also rename http2configureTransport in net/http to follow the internal rename that happened in CL 264017 to fix the build. For #36905. Updates #41721. Updates #42498. Change-Id: Ifcd2e76f0406e389b6db88041ca51cd0a2115152 Reviewed-on: https://go-review.googlesource.com/c/go/+/266898 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2020-11-09crypto/tls: add HandshakeContext method to ConnJohan Brandhorst
Adds the (*tls.Conn).HandshakeContext method. This allows us to pass the context provided down the call stack to eventually reach the tls.ClientHelloInfo and tls.CertificateRequestInfo structs. These contexts are exposed to the user as read-only via Context() methods. This allows users of (*tls.Config).GetCertificate and (*tls.Config).GetClientCertificate to use the context for request scoped parameters and cancellation. Replace uses of (*tls.Conn).Handshake with (*tls.Conn).HandshakeContext where appropriate, to propagate existing contexts. Fixes #32406 Change-Id: I33c228904fe82dcf57683b63627497d3eb841ff2 Reviewed-on: https://go-review.googlesource.com/c/go/+/246338 Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-11-05net/mail: avoid ParseDate confusion if day name includes "T"Emmanuel T Odeke
Fixes the check for RFC 5322 "obsolete time zone" to ensure that we correctly extract the entire date from the "T" of the implied time zone. Obsolete Time zones come in the form: * GMT * PST * MDT etc, as per Section 4.3 of RFC 5322, https://tools.ietf.org/html/rfc5322#section-4.3. The prior check from CL 117596 erronenously used strings.Index which selects the first "T", and that meant that dates containing days "Tue" or "Thu" could not be parsed. We also now deal with "T" in the CFWS "Comment Folding White Space". Thus we'll now accept dates: * Thu, 20 Nov 1997 09:55:06 MDT * Thu, 20 Nov 1997 09:55:06 MDT (MDT) * Fri, 21 Nov 1997 09:55:06 MDT (This comment) * Fri, 21 Nov 1997 09:55:06 MDT (MDT Fixes #39260 Change-Id: I6d59d99bc4f05a82582c826b5c5a080a25fd999b Reviewed-on: https://go-review.googlesource.com/c/go/+/235200 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-28net/url: improve performance for resolvePathimxyb
benchmark compare results: benchmark old ns/op new ns/op delta BenchmarkResolvePath-12 297 141 -52.53% benchmark old allocs new allocs delta BenchmarkResolvePath-12 5 3 -40.00% benchmark old bytes new bytes delta BenchmarkResolvePath-12 181 24 -86.74% Change-Id: Ia69e9fb36abb5930ed49217b5219be62b57ec429 GitHub-Last-Rev: e16dd9f7415178120f67f472bf45a2b006e00a93 GitHub-Pull-Request: golang/go#42180 Reviewed-on: https://go-review.googlesource.com/c/go/+/264817 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-27net/http: use exponential backoff for polling in Server.ShutdownDan Peterson
Instead of always polling 500ms, start with an interval of 1ms and exponentially back off to at most 500ms. 10% jitter is added to each interval. This makes Shutdown more responsive when connections and listeners close quickly. Also removes the need for the polling interval to be changed in tests since if tests' connections and listeners close quickly Shutdown will also return quickly. Fixes #42156 Change-Id: I5e59844a2980c09adebff57ae8b58817965e6db4 Reviewed-on: https://go-review.googlesource.com/c/go/+/264479 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Bryan C. Mills <bcmills@google.com>
2020-10-25net: prefer /etc/hosts over DNS when no /etc/nsswitch.conf is presentNatanael Copa
Do not mimic glibc behavior if /etc/nsswitch.conf is missing. This will will likely be missing on musl libc systems and glibc systems will likely always have it, resulting in localhost lookup being done over DNS rather than from /etc/hosts. Do what makes most sense rather than making any assumption about the libc. Fixes #35305 Change-Id: I20bd7e24131bba8eaa39a20c8950fe552364784d GitHub-Last-Rev: 119409839d37c8c7268f5f6db19c1789d9d96074 GitHub-Pull-Request: golang/go#39685 Reviewed-on: https://go-review.googlesource.com/c/go/+/238629 Run-TryBot: Dan Peterson <dpiddy@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Peterson <dpiddy@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Emmanuel Odeke <emmanuel@orijtech.com>
2020-10-24net/http: fix typo in TestTransportReadToEndReusesConnKeiichi Hirobe
The test sets a Content-Type where it looks like it wants a Content-Length. The test passes because the Content-Length header is automatically added anyway, but fix the typo and set Content-Length as intended. Change-Id: Ic2af778f82c3e9d58e164892f6ac6ef5745f884f Reviewed-on: https://go-review.googlesource.com/c/go/+/246977 Reviewed-by: Damien Neil <dneil@google.com> Trust: Alberto Donizetti <alb.donizetti@gmail.com> Trust: Damien Neil <dneil@google.com> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-21net: add Example for Unix dialer with contextKevin Burke
Showing users how to accomplish this more easily is a compromise between doing nothing and adding a new API to the net package. Fixes #38506. Change-Id: I43f831cf94951c987cf3c8c1aa55f0012ee8034e Reviewed-on: https://go-review.googlesource.com/c/go/+/263417 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-21net/http: test that ParseMultipartForm catches overflowsEmmanuel T Odeke
Tests that if the combination of: * HTTP multipart file payload size * ParseMultipartForm's maxMemory parameter * the internal leeway buffer size of 10MiB overflows, then we'll report an overflow instead of silently passing. Reapplies and fixes CL 254977, which was reverted in CL 263658. The prior test lacked a res.Body.Close(), so fixed that and added a leaked Transport check to verify correctness. Updates 40430. Change-Id: I3c0f7ef43d621f6eb00f07755f04f9f36c51f98f Reviewed-on: https://go-review.googlesource.com/c/go/+/263817 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Trust: Damien Neil <dneil@google.com>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-20net/http: add FS to convert fs.FS to FileSystemRuss Cox
Two different functions in the http API expect a FileSystem: http.FileSystem and http.NewFileTransport. Add a general converter http.FS to turn an fs.FS into an http.FileSystem for use with either of these functions. (The original plan was to add http.HandlerFS taking an fs.FS directly, but that doesn't help with NewFileTransport.) For #41190. Change-Id: I5f242eafe9b963f4387419a2615bdb487c358f16 Reviewed-on: https://go-review.googlesource.com/c/go/+/243939 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-10-20net/http/cgi: preserve env vars on illumosTobias Klauser
Preserve the same environment variables as on solaris. Spotted while reviewing CL 263577. Change-Id: Id479dcf83d6231e9ef1fd2404b400d10082e1d0b Reviewed-on: https://go-review.googlesource.com/c/go/+/263802 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-20net/http/cgi: preserve LD_LIBRARY_PATH on NetBSD, tooNikhil Benesch
This makes the behavior of the cgi package on NetBSD consistent with its behavior on the other BSDs. It is also necessary for the test suite to pass on NetBSD with gccgo (see CL 261137). Change-Id: I531a6e0954f895a921204dcc61e3f3e90860a23d Reviewed-on: https://go-review.googlesource.com/c/go/+/263577 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Trust: Benny Siegert <bsiegert@gmail.com>
2020-10-20all: update references to symbols moved from os to io/fsRuss Cox
The old os references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. For #41190. Change-Id: I8f9526977867c10a221e2f392f78d7dec073f1bd Reviewed-on: https://go-review.googlesource.com/c/go/+/243907 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-10-19Revert "net/http: test that ParseMultipartForm returns an error for int ↵Bryan C. Mills
overflow" This reverts CL 254977. Reason for revert: introduced test failures on longtest builders. Change-Id: I75e868245f980189ad85dd4103d9178989e06ecf Reviewed-on: https://go-review.googlesource.com/c/go/+/263658 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2020-10-19net/http: test that ParseMultipartForm returns an error for int overflowavivklas
ParseMultipartForm has been changed to return an error if maxMemory parameter + 10MB causes int overflows. This adds a test for the new behaviour. For #40430 Change-Id: I4f66ce8a9382940182011d22a84ee52b1d1364cf Reviewed-on: https://go-review.googlesource.com/c/go/+/254977 Reviewed-by: Damien Neil <dneil@google.com> Trust: Damien Neil <dneil@google.com> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-19net/http/httputil: copy response header back to http.ResponseWriter in ↵Aofei Sheng
ReverseProxy.handleUpgradeResponse Fixes: #41634 Change-Id: Ib78cc37a4d2ca0753d567eafb616238e4103484e Reviewed-on: https://go-review.googlesource.com/c/go/+/257777 Reviewed-by: Damien Neil <dneil@google.com> Trust: Damien Neil <dneil@google.com> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>