aboutsummaryrefslogtreecommitdiff
path: root/src/net
AgeCommit message (Collapse)Author
2023-02-17net/http: remove five second timeout from TestTransportClosesBodyOnErrorDamien Neil
Wait forever and let the test time out with a stack trace if the expected response doesn't happen. Fixes #57990 Change-Id: I835def63db113752cdd06e03e258cb10d63a6a25 Reviewed-on: https://go-review.googlesource.com/c/go/+/463222 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-15net: retry if GetAddrInfoW returns WSTRY_AGAIN when resolving an IPzen
GetAddrInfoW is retried now multiple times as per the timeout and number of retries defined in func dnsReadConfig (before it was called only once) Fixes #55050 Change-Id: If5369ebb164d98557a802de938756dbf9c125773 Reviewed-on: https://go-review.googlesource.com/c/go/+/462051 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-15net/http: support streaming POST content in wasmWill Hawkins
With new releases of Chrome, Opera and Deno it is possible to stream the body of a POST request. Add support for using that interface when it is available. Change-Id: Ib23d63cd3dea634bd9e267abf4e9a9bfa9c525ad Reviewed-on: https://go-review.googlesource.com/c/go/+/458395 Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-02-14mime/multipart: limit memory/inode consumption of ReadFormDamien Neil
Reader.ReadForm is documented as storing "up to maxMemory bytes + 10MB" in memory. Parsed forms can consume substantially more memory than this limit, since ReadForm does not account for map entry overhead and MIME headers. In addition, while the amount of disk memory consumed by ReadForm can be constrained by limiting the size of the parsed input, ReadForm will create one temporary file per form part stored on disk, potentially consuming a large number of inodes. Update ReadForm's memory accounting to include part names, MIME headers, and map entry overhead. Update ReadForm to store all on-disk file parts in a single temporary file. Files returned by FileHeader.Open are documented as having a concrete type of *os.File when a file is stored on disk. The change to use a single temporary file for all parts means that this is no longer the case when a form contains more than a single file part stored on disk. The previous behavior of storing each file part in a separate disk file may be reenabled with GODEBUG=multipartfiles=distinct. Update Reader.NextPart and Reader.NextRawPart to set a 10MiB cap on the size of MIME headers. Thanks to Jakob Ackermann (@das7pad) for reporting this issue. Fixes #58006 Fixes CVE-2022-41725 Change-Id: Ibd780a6c4c83ac8bcfd3cbe344f042e9940f2eab Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1714276 Reviewed-by: Julie Qiu <julieqiu@google.com> TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <bracewell@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/468124 Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-14all: fix some commentscui fliter
Change-Id: I16ec916b47de2f417b681c8abff5a1375ddf491b Reviewed-on: https://go-review.googlesource.com/c/go/+/468055 Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-02-13all: update vendored golang.org/x/netDamien Neil
Pull in HTTP/2 fix to deflake builders: 547e7edf38 http2: avoid referencing ResponseWrite.Write parameter after returning For #58446 Change-Id: I7f3666bc1f20ee03a7ccf25f0e091033cbc635d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/467657 Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-10net: move context cancellation logic of blocking calls to a common functionMateusz Poliwczak
Follow up of CL 464375 which reverted the CL 463231, because of a data race. Change-Id: I1a52f23a68a6981b902fc59bda1437bd169ca22b GitHub-Last-Rev: 0157bd01807a731239f3f2940d440e798be33d83 GitHub-Pull-Request: golang/go#58383 Reviewed-on: https://go-review.googlesource.com/c/go/+/465836 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-02-10vendor, cmd/vendor: update standard library dependenciesDavid Chase
Change-Id: I6facfae14e850f6c9bf3bcb53489c8b475bbb860 Reviewed-on: https://go-review.googlesource.com/c/go/+/467297 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: David Chase <drchase@google.com>
2023-02-10Revert "io: allocate copy buffers from a pool"Damien Neil
This reverts CL 456555. Reason for revert: This seems too likely to exercise race conditions in code where a Write call continues to access its buffer after returning. The HTTP/2 ResponseWriter is one such example. Reverting this change while we think about this some more. For #57202 Change-Id: Ic86823f81d7da410ea6b3f17fb5b3f9a979e3340 Reviewed-on: https://go-review.googlesource.com/c/go/+/467095 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-09net: remove unused cname return from cgoLookupIPCNAMEMateusz Poliwczak
Change-Id: I4f9b84696f55c6b381de60682f8b242098b95b75 GitHub-Last-Rev: 74a6013a9e668119a0895c1250c3d4592bfd4072 GitHub-Pull-Request: golang/go#58402 Reviewed-on: https://go-review.googlesource.com/c/go/+/466335 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2023-02-09net/http: improve js fetch errorsJohan Brandhorst-Satzkorn
The Error type used in failed fetch invocations contain more information than we're currently extracting. Optimistically look for the cause field for extra context for errors. Change-Id: I6c8e4b230a21ec684af2107707aa605fc2148fcf Reviewed-on: https://go-review.googlesource.com/c/go/+/463978 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Evan Phoenix <evan@phx.io> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-02-04net/http/httputil: fix syntax in ReverseProxy example commentEthan Lowman
Change-Id: I7e71626246af94047fbd1abb9bb77f2cd9b281fb Reviewed-on: https://go-review.googlesource.com/c/go/+/465195 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2023-02-02net/netip: fix invalid representation of PrefixJoe Tsai
For a given Addr, ensure there is exactly one invalid representation. This allows invalid representations to be safely comparable. To ensure that the zero value of Prefix is invalid, we modify the encoding of bits to simply be the bit count plus one. Since Addr is immutable, we check in the PrefixFrom constructor that the provided Addr is valid and only store a non-zero bits length if so. IsValid is simplified to just checking whether bitsPlusOne is non-zero. Fixes #54525 Change-Id: I9244cae2fd160cc9c81d007866992df2e422d3b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/425035 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
2023-02-01net/http: remove another arbitrary timeout in TestTLSHandshakeTimeoutBryan C. Mills
Updates #37327 Change-Id: I87774be71ed54e9c45a27062122e6177888e890a Reviewed-on: https://go-review.googlesource.com/c/go/+/226137 Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2023-01-31net/netip: use IPv6Loopback in TestIPPropertiesTobias Klauser
Change-Id: I667bdaf52e9d32cd89e396616057bc57ecaffe09 Reviewed-on: https://go-review.googlesource.com/c/go/+/463836 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-31net: use net/netip for address parsingMateusz Poliwczak
Fixes #58098 Change-Id: I6ef963ba2c110215b8eda763cbfb258a25c8199a GitHub-Last-Rev: 3d22f076b725337fa97eedcf92a1520a72bf0c17 GitHub-Pull-Request: golang/go#58143 Reviewed-on: https://go-review.googlesource.com/c/go/+/463987 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-01-31Revert "net: move context cancellation logic of blocking calls to a common ↵Bryan Mills
function." This reverts CL 463231. Reason for revert: introduced a data race on darwin. Fixes #58169. Change-Id: I35f02273db38c257369c166547bb4945f92fdc3a Reviewed-on: https://go-review.googlesource.com/c/go/+/464375 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-31net: report IsNotFound when getnameinfo returns EAI_NONAMEMateusz Poliwczak
Fixes #57548 Change-Id: I4092624b1e906fbcd520f43aa4bc71c144dea3b6 GitHub-Last-Rev: ab048359473978ee245188710b6d6e12d50fb0ab GitHub-Pull-Request: golang/go#57549 Reviewed-on: https://go-review.googlesource.com/c/go/+/460255 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-31net: move context cancellation logic of blocking calls to a common function.Mateusz Poliwczak
Change-Id: I5f7219a111436e3d6a4685df9461f5a8f8bcb000 GitHub-Last-Rev: e420129bade2681d2b6ce92087ed94444f424810 GitHub-Pull-Request: golang/go#58108 Reviewed-on: https://go-review.googlesource.com/c/go/+/463231 Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-31io: allocate copy buffers from a poolDamien Neil
CopyBuffer allocates a 32k buffer when no buffer is available. Allocate these buffers from a sync.Pool. This removes an optimization where the copy buffer size was reduced when the source is a io.LimitedReader (including the case of CopyN) with a limit less than the default buffer size. This change could cause a program which only uses io.Copy with sources with a small limit to allocate unnecessarily large buffers. Programs which care about the transient buffer allocation can avoid this by providing their own buffer. name old time/op new time/op delta CopyNSmall-10 165ns ± 7% 117ns ± 7% -29.19% (p=0.001 n=7+7) CopyNLarge-10 7.33µs ±34% 4.07µs ± 2% -44.52% (p=0.001 n=7+7) name old alloc/op new alloc/op delta CopyNSmall-10 2.20kB ±12% 1.20kB ± 4% -45.24% (p=0.000 n=8+7) CopyNLarge-10 148kB ± 9% 81kB ± 4% -45.26% (p=0.000 n=8+7) name old allocs/op new allocs/op delta CopyNSmall-10 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=8+8) CopyNLarge-10 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=8+8) For #57202 Change-Id: I2292226da9ba1dc09a2543f5d74fe5da06080d49 Reviewed-on: https://go-review.googlesource.com/c/go/+/456555 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Thomas Austad <thomas.austad@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-30net/http: add section headers to package docRuss Cox
Change-Id: I2379cceeb74cb8511058b24cdd100b21649505ce Reviewed-on: https://go-review.googlesource.com/c/go/+/462197 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2023-01-30net/http: disable fetch on NodeJSJohan Brandhorst-Satzkorn
NodeJS 18 introduced support for the fetch API for making HTTP requests. This broke all wasm tests that were relying on NodeJS falling back to the fake network implementation in net_fake.go. Disable the fetch API on NodeJS to get tests passing. Fixes #57613 Change-Id: Icb2cce6d5289d812da798e07366f8ac26b5f82cb Reviewed-on: https://go-review.googlesource.com/c/go/+/463976 Reviewed-by: Evan Phoenix <evan@phx.io> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-27net/http: fix missing word in ServeMux docOleksii Sholik
Change-Id: I324cedfcdfa1d7eac7be43dc89febb584359c8e3 GitHub-Last-Rev: 7724cd84f323b531215db0406f72481394d0b206 GitHub-Pull-Request: golang/go#57799 Reviewed-on: https://go-review.googlesource.com/c/go/+/462039 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com>
2023-01-27net: report completed when context is done in cgoLookupIP and cgoLookupPTRMateusz Poliwczak
All the Lookup* methods that resolve hostnames eventually call lookupIP or lookupHost method. When the order is selected to be hostLookupCGO then lookupHost calls cgoLookupHost which internally calls cgoLookupIP (the lookupIP directly calls cgoLookupIP). When we provide a context that is cancelled after cgo call, then the cgoLookupIP returns completed == false, which caues the lookupIP/lookupHost to fallback to the go resolver. This fallback is unnecessary because our context is already cancelled. The same thing can happen to LookupAddr. Change-Id: Ifff7716c461f05d954ef43b5205865103558b410 GitHub-Last-Rev: 2ef2023e8c51cdd251986f79e94aba86a0722230 GitHub-Pull-Request: golang/go#57042 Reviewed-on: https://go-review.googlesource.com/c/go/+/454696 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-01-26net/http: keep sensitive headers on redirects to the same hostGustavo Falco
Preserve sensitive headers on a redirect to a different port of the same host. Fixes #35104 Change-Id: I5ab57c414ce92a70e688ee684b9ff02fb062b3c6 GitHub-Last-Rev: 8d53e71e2243c141d70d27a503d0f7e6dee64c3c GitHub-Pull-Request: golang/go#54539 Reviewed-on: https://go-review.googlesource.com/c/go/+/424935 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com>
2023-01-21net: add testing.Short Skip to test affected by local network configurationDavid Chase
If the local network mangles invalid DNS queries, that is not a Go problem. Change-Id: I54db392532eed988bca81b70a98cd6d11766af89 Reviewed-on: https://go-review.googlesource.com/c/go/+/461275 Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-01-20net/http: close Request.Body when pconn write loop exits earlyDamien Neil
The pconn write loop closes a request's body after sending the request, but in the case where the write loop exits with an unsent request in writech the body is never closed. Close the request body in this case. Fixes #49621 Change-Id: Id94a92937bbfc0beb1396446f4dee32fd2059c7e Reviewed-on: https://go-review.googlesource.com/c/go/+/461675 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2023-01-19internal/godebug: export non-default-behavior counters in runtime/metricsRuss Cox
Allow GODEBUG users to report how many times a setting resulted in non-default behavior. Record non-default-behaviors for all existing GODEBUGs. Also rework tests to ensure that runtime is in sync with runtime/metrics.All, and generate docs mechanically from metrics.All. For #56986. Change-Id: Iefa1213e2a5c3f19ea16cd53298c487952ef05a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/453618 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-01-19runtime: replace panic(nil) with panic(new(runtime.PanicNilError))Russ Cox
Long ago we decided that panic(nil) was too unlikely to bother making a special case for purposes of recover. Unfortunately, it has turned out not to be a special case. There are many examples of code in the Go ecosystem where an author has written panic(nil) because they want to panic and don't care about the panic value. Using panic(nil) in this case has the unfortunate behavior of making recover behave as though the goroutine isn't panicking. As a result, code like: func f() { defer func() { if err := recover(); err != nil { log.Fatalf("panicked! %v", err) } }() call1() call2() } looks like it guarantees that call2 has been run any time f returns, but that turns out not to be strictly true. If call1 does panic(nil), then f returns "successfully", having recovered the panic, but without calling call2. Instead you have to write something like: func f() { done := false defer func() { if err := recover(); !done { log.Fatalf("panicked! %v", err) } }() call1() call2() done = true } which defeats nearly the whole point of recover. No one does this, with the result that almost all uses of recover are subtly broken. One specific broken use along these lines is in net/http, which recovers from panics in handlers and sends back an HTTP error. Users discovered in the early days of Go that panic(nil) was a convenient way to jump out of a handler up to the serving loop without sending back an HTTP error. This was a bug, not a feature. Go 1.8 added panic(http.ErrAbortHandler) as a better way to access the feature. Any lingering code that uses panic(nil) to abort an HTTP handler without a failure message should be changed to use http.ErrAbortHandler. Programs that need the old, unintended behavior from net/http or other packages can set GODEBUG=panicnil=1 to stop the run-time error. Uses of recover that want to detect panic(nil) in new programs can check for recover returning a value of type *runtime.PanicNilError. Because the new GODEBUG is used inside the runtime, we can't import internal/godebug, so there is some new machinery to cross-connect those in this CL, to allow a mutable GODEBUG setting. That won't be necessary if we add any other mutable GODEBUG settings in the future. The CL also corrects the handling of defaulted GODEBUG values in the runtime, for #56986. Fixes #25448. Change-Id: I2b39c7e83e4f7aa308777dabf2edae54773e03f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/461956 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org>
2023-01-19net: delete TestTCPSelfConnectBryan C. Mills
This test is flaky, apparently due to a typo'd operator in CL 21447 that causes it to compare “same port OR IP” instead of “same port AND IP”. If we merely fixed the comparison, the test would hopefully stop being flaky itself, but we would still be left with another problem: repeatedly dialing a port that we believe to be unused can interfere with other tests, which may open the previously-unused port and then attempt a single Dial and expect it to succeed. Arbitrary other Dial calls for that port may cause the wrong connection to be accepted, leading to spurious test failures. Moreover, the test can be extremely expensive for the amount of data we hope to get from it, depending on the system's port-reuse algorithms and dial implementations. It is already scaled back by up to 1000x on a huge number of platforms due to latency, and may even be ineffective on those platforms because of the arbitrary 1ms Dial timeout. And the incremental value from it is quite low, too: it tests the workaround for what is arguably a bug in the Linux kernel, which ought to be fixed (and tested) upstream instead of worked around in every open-source project that dials local ports. Instead of trying to deflake this test, let's just get rid of it. Fixes #18290. Change-Id: I8a58b93d67916a33741c9ab29ef99c49c46b32c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/460657 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
2023-01-19net/netip: fix type name in TestNoAllocs sub-test names and commentsTobias Klauser
netaddr.IP became netip.Addr Change-Id: Ifa762d0f804c603e6289d63672e4808e75dc36a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/461748 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2023-01-06net: fix typo in hosts.goIkko Eltociear Ashimine
cannonical -> canonical Change-Id: I656ea210d8ef6eaa85245cb8f463f6b4fd67e1a2 GitHub-Last-Rev: 5a93045add2f2a6885b46377c784f665ab465cfd GitHub-Pull-Request: golang/go#57633 Reviewed-on: https://go-review.googlesource.com/c/go/+/460756 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-12-21net/http/httputil: don't add X-Forwarded-{Host,Proto} after invoking ↵Damien Neil
Director funcs This reverts CL 407414. When forwarding an inbound request that contains an existing X-Forwarded-Host or X-Forwarded-Proto header, a proxy might want to preserve the header from the inbound request, replace it with its own header, or not include any header at all. CL 407414 replaces inbound X-Forwarded-{Host,Proto} headers by default, and allows a Director func to disable sending these headers at all. However, the Director hook API isn't sufficiently flexible to permit the previous behavior of preserving inbound values unchanged. The new Rewrite API does have this flexibility; users of Rewrite can easily pick the exact behavior they want. Revert the change to ReverseProxy when using a Director func. Users who want a convenient way to set X-Forwarded-* headers to reasonable values can migrate to Rewrite at their convenience, and users depending on the current behavior will be unaffected. For #50465. Fixes #57132. Change-Id: Ic42449c1bb525d6c9920bf721efbc519697f4f20 Reviewed-on: https://go-review.googlesource.com/c/go/+/457595 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-12-21net: use correct dns msg sizeMateusz Poliwczak
Set bufSize to the actual dns message size, so that the p.Start (below) gets a fully valid dns message. Change-Id: I585e8a3d71f88db93e09bd0dbbc0875ee6de9a97 GitHub-Last-Rev: 0967be35012d2e28366e6d47eee4968c7e8d5e4a GitHub-Pull-Request: golang/go#57392 Reviewed-on: https://go-review.googlesource.com/c/go/+/458375 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-16os/user,net: add -fno-stack-protector to CFLAGSThan McIntosh
Some compilers default to having -fstack-protector on, which breaks when using internal linking because the linker doesn't know how to find the support functions. Updates #52919. Updates #54313. Fixes #57261. Change-Id: Iaae731851407af4521fff2dfefc5b7e3e92cf284 Reviewed-on: https://go-review.googlesource.com/c/go/+/456855 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-16net/http: improve errors in TestCancelRequestWhenSharingConnectionDamien Neil
Provide more information about why this test might be hanging waiting for PutIdleConn to be called (#56587): If the round trip that should result in PutIdleConn being invoked completes, report that to the goroutine waiting for PutIdleConn. For #56587 Change-Id: Ie476ea0ce4a48d2bda6b9b109f89d675a10e7e45 Reviewed-on: https://go-review.googlesource.com/c/go/+/457775 Auto-Submit: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-12-07all: update vendored golang.org/x/netDamien Neil
Pull in HTTP/2 security fix: 1e63c2f08a http2: limit canonical header cache by bytes, not entries Fixes #56350 Change-Id: Ib14024ed894ba266f05d4a6e8c454234a45677d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/455717 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Jenny Rakoczy <jenny@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-06os, net/http: avoid escapes from os.DirFS and http.Dir on WindowsDamien Neil
Do not permit access to Windows reserved device names (NUL, COM1, etc.) via os.DirFS and http.Dir filesystems. Avoid escapes from os.DirFS(`\`) on Windows. DirFS would join the the root to the relative path with a path separator, making os.DirFS(`\`).Open(`/foo/bar`) open the path `\\foo\bar`, which is a UNC name. Not only does this not open the intended file, but permits reference to any file on the system rather than only files on the current drive. Make os.DirFS("") invalid, with all file access failing. Previously, a root of "" was interpreted as "/", which is surprising and probably unintentional. Fixes CVE-2022-41720 Fixes #56694 Change-Id: I275b5fa391e6ad7404309ea98ccc97405942e0f0 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1663834 Reviewed-by: Tatiana Bradley <tatianabradley@google.com> Reviewed-by: Julie Qiu <julieqiu@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/455362 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Jenny Rakoczy <jenny@golang.org> Reviewed-on: https://go-review.googlesource.com/c/go/+/455716 Reviewed-by: Jenny Rakoczy <jenny@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2022-12-05net: support context cancellation in resSearchMateusz Poliwczak
As with all the stuff that call cgo from net package. Change-Id: I7c42ae44a1d47f4f949b203682217498fcdba92a GitHub-Last-Rev: 70406493bbbe10bf556a17e453623d3decf00822 GitHub-Pull-Request: golang/go#57043 Reviewed-on: https://go-review.googlesource.com/c/go/+/454697 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-12-01net: acquire thread in resSearchMateusz Poliwczak
Change-Id: I042906d8eee8defafbd98f671fd30c2a68281705 GitHub-Last-Rev: 0660c9a989600eeb8652d1228777488d28397731 GitHub-Pull-Request: golang/go#57021 Reviewed-on: https://go-review.googlesource.com/c/go/+/454396 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-12-01net: retry with bigger buffer in resSearchMateusz Poliwczak
Glibc returns size > bufSize, when the entire dns reply does not fit inside the provided buffer. Change-Id: Ie1c1c6a3411880bd8bdb4371f1f1b7bcce837ea2 GitHub-Last-Rev: 488cd3ed0db2a86433aa921117b8f1e9192b1fa5 GitHub-Pull-Request: golang/go#57020 Reviewed-on: https://go-review.googlesource.com/c/go/+/454395 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-11-30net: reenable SRV tests with _ldap._tcp.google.comDamien Neil
TestLookupDotsWithRemoteSource and TestLookupGoogleSRV were disabled because they look up the no-longer-present SRV record for _xmpp-server._tcp.google.com. Change the tests to look for _ldap._tcp.google.com and reenable them. Fixes #56708. Change-Id: I26475fa3ff6fc008048a4e5f24f0e96ee12f655c Reviewed-on: https://go-review.googlesource.com/c/go/+/453861 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-30net/http: deflake and fix TestWrappedResponseControllerDamien Neil
Read the full (empty) response body before closing it, to avoid cancelling the request while the server handler is still running. Wrap the ResponseWriter before calling NewResponseController: This test is intended to verify that wrapping the controller works properly, but neglected to actually wrap the controller. Fixes #56961. Change-Id: I00269f897448ab34676338707b7a04d19ff17963 Reviewed-on: https://go-review.googlesource.com/c/go/+/453860 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-28net: gofmt after CL 382996Tobias Klauser
Change-Id: Ic1302eb02f4369bf6758be9fb91379fd9a992e48 Reviewed-on: https://go-review.googlesource.com/c/go/+/453575 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-11-22all: enable disabled HTTP/2 testsDamien Neil
Update net/http to enable tests that pass with the latest update to the vendored x/net. Update a few tests: Windows apparently doesn't guarantee that time.Since(time.Now()) is >=0, so to set a definitely-expired write deadline, use a time firmly in the past rather than now. Put a backoff loop on TestServerReadTimeout to avoid failures when the timeout expires mid-TLS-handshake. (The TLS handshake timeout is set to min(ReadTimeout, WriteTimeout, ReadHeaderTimeout); there's no way to set a long TLS handshake timeout and a short read timeout.) Don't close the http.Server in TestServerWriteTimeout while the handler may still be executing, since this can result in us getting the wrong error. Change the GOOS=js fake net implementation to properly return ErrDeadlineExceeded when a read/write deadline is exceeded, rather than EAGAIN. For #49837 For #54136 Change-Id: Id8a4ff6ac58336ff212dda3c8799b320cd6b9c19 Reviewed-on: https://go-review.googlesource.com/c/go/+/449935 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-11-22Revert "net/url, net/http/httputil: accept invalid percent encodings"Damien Neil
This reverts CL 450375. Reason for revert: This change causes test failures (and possibly other problems) for users depending on the existing validation behavior. Rolling back the change for now to give us more time to consider its impact. This landed late in the cycle and isn't urgent; it can wait for 1.21 if we do want to make the change. Fixes #56884 For #56732 Change-Id: I082023c67f1bbb933a617453ab92b67abba876ef Reviewed-on: https://go-review.googlesource.com/c/go/+/452795 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-11-22all: update vendored golang.org/x dependencies for Go 1.20 releaseCherry Mui
The Go 1.20 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. This CL updates them with x/build/cmd/updatestd. For #36905. Change-Id: Ie0ec91daeb848f00f64686003012297161ad02fa Reviewed-on: https://go-review.googlesource.com/c/go/+/452766 Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-11-19net/http: deflake TestIssue4191_InfiniteGetTimeoutDamien Neil
This test exercises the case where a net.Conn error occurs while writing a response body. It injects an error by setting a timeout on the Conn. If this timeout expires before response headers are written, the test fails. The test attempts to recover from this failure by extending the timeout and retrying. Set the timeout after the response headers are removed, and remove the retry loop. Fixes #56274. Change-Id: I293f8bedb7b20a21d14f43ea9bb48fc56b59441c Reviewed-on: https://go-review.googlesource.com/c/go/+/452175 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Damien Neil <dneil@google.com>
2022-11-19net/http: direct server logs to test output in testsDamien Neil
Set a logger in newClientServerTest that directs the server log output to the testing.T's log, so log output gets properly associated with the test that caused it. Change-Id: I13686ca35c3e21adae16b2fc37ce36daea3df9d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/452075 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-18net/http: regenerate h2_bundle.goDmitri Shuralyov
Done with: go generate -run=bundle std After CL 452096 updated the x/net version. Change-Id: I1c1cd76d4ec9e14f45dc66c945c74e41ff689a30 Reviewed-on: https://go-review.googlesource.com/c/go/+/452195 Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>