summaryrefslogtreecommitdiff
path: root/src/net
Commit message (Collapse)AuthorAgeFilesLines
* net: disable TestIPv6WriteMsgUDPAddrPortTargetAddrIPVersion [sic] on ↵Russ Cox2022-08-031-1/+3
| | | | | | | | | | | | | | DragonflyBSD Like OpenBSD, DragonflyBSD does not do IPv4-in-IPv6 mapping. For #52264. Change-Id: Id41606e75652e684f2e0e98c6459156641aec9b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/420775 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: document UDPConn.ReadFromUDPAddrPort's AddrPort result moreBrad Fitzpatrick2022-07-271-0/+4
| | | | | | | | | | | | | | | Clarify the form of its IPv4 addresses when listening on an unspecified address. (found while testing/reviewing CL 399454) Change-Id: I62b367f5a4e6d340eb72dd7ec342080f1821e63e Reviewed-on: https://go-review.googlesource.com/c/go/+/419614 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* net: fix WriteMsgUDPAddrPort addr handlingdatabase641282022-07-262-1/+48
| | | | | | | | | | | | | | | | | WriteMsgUDPAddrPort should accept IPv4 target addresses on IPv6 UDP sockets. An IPv4 target address will be converted to an IPv4-mapped IPv6 address. Fixes #52264. Change-Id: Ib9ed4c61fa1289ae7bbc8c4c9de1a9951b647ec0 GitHub-Last-Rev: 6776fdb0a76faa71ebde58f5143fb1ffb3112adf GitHub-Pull-Request: golang/go#52265 Reviewed-on: https://go-review.googlesource.com/c/go/+/399454 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: remove accidental heading in Head documentationDmitri Shuralyov2022-07-211-1/+1
| | | | | | | | | | | | | | | | | This short sentence was missing a period at the end, which caused it to be interpreted as a heading. It also gained a '# ' prefix as part of new gofmt formatting applied in CL 384268. This change makes it a regular sentence as originally intended. Updates #51082. Change-Id: I100410cca21e4f91130f1f3432327bb6d66b12a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/418959 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* http: improve Get documentationminherz2022-07-181-1/+2
| | | | | | | | | | | | | | | | The existing documentation is unclear about header keys formatting. The clarifying sentence is added to Get function to emphasis that keys have to be stored in canonical format to have Get returining non empty value. Fixes #53140 Change-Id: Icd0955bcbb6676cec028fe37042aed5846e13ed1 Reviewed-on: https://go-review.googlesource.com/c/go/+/417975 Run-TryBot: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
* net/http: clarify that MaxBytesReader returns *MaxBytesErrorDamien Neil2022-07-121-2/+2
| | | | | | | | | | | | | A MaxBytesReader returns a *MaxBytesError when reading beyond its limit, not a MaxBytesError. Fixes #53764. Change-Id: Icac3aeac96fd8b172f951241f8f111cda633752c Reviewed-on: https://go-review.googlesource.com/c/go/+/416914 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net/url: use EscapedPath for url.JoinPathSean Liao2022-07-112-1/+11
| | | | | | | | | | | Fixes #53763 Change-Id: I08b53f159ebdce7907e8cc17316fd0c982363239 Reviewed-on: https://go-review.googlesource.com/c/go/+/416774 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* net/http: remove Content-Encoding in writeNotModifiedMitar2022-07-112-0/+55
| | | | | | | | | | | | | | | Additional header to remove if set before calling http.ServeContent. The API of ServeContent is that one should set Content-Encoding before calling it, if the content is encoded (e.g., compressed). But then, if content has not been modified, that header should be removed, according to RFC 7232 section 4.1. Change-Id: If51b35b7811a4dbb19de2ddb73f40c5e68fcec7e GitHub-Last-Rev: 53df6e73c44b63f351f7aeeb45cab82d706311eb GitHub-Pull-Request: golang/go#50903 Reviewed-on: https://go-review.googlesource.com/c/go/+/381955 Run-TryBot: hopehook <hopehook@qq.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
* net/http: wait for listeners to exit in Server.Close and ShutdownDamien Neil2022-07-081-7/+15
| | | | | | | | | | | | | | | | | | | | | Avoid race conditions when a new connection is accepted just after Server.Close or Server.Shutdown is called by waiting for the listener goroutines to exit before proceeding to clean up active connections. No test because the mechanism required to trigger the race condition reliably requires such tight coupling to the Server internals that any test would be quite fragile in the face of reasonable refactorings. Fixes #48642 Updates #33313, #36819 Change-Id: I109a93362680991bf298e0a95637595dcaa884af Reviewed-on: https://go-review.googlesource.com/c/go/+/409537 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* net/http: omit invalid header value from error messageAlexander Yastrebov2022-07-012-9/+10
| | | | | | | | | | | | | | Updates #43631 Change-Id: I0fe3aafdf7ef889fed1a830128721393f8d020e6 GitHub-Last-Rev: c359542d741b17f4e2cb0d50982bf341246233b0 GitHub-Pull-Request: golang/go#48979 Reviewed-on: https://go-review.googlesource.com/c/go/+/355929 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* os: simplify deadline fluctuation testsIan Lance Taylor2022-06-301-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This applies the net package CL 365334, CL 366176, CL 372215 to the os package. CL 365334: These tests were checking for fairly narrow timing windows, but were running in parallel and heavily dependent on timer and goroutine scheduling. This change eliminates unnecessary goroutines, runs the tests sequentially (dramatically shortening the timeouts to reduce the penalty of doing so), and uses timestamp comparison instead of background timers to hopefully gain some robustness from monotonic timestamps. Many of the other tests from this package would benefit from similar simplifications, which we can apply if and when we notice flaky failures or want to improve the latency of running the test. CL 366176: It appears that at least the OpenBSD kernel gets sloppier the longer the timeout we give it, up to an observed overhead of around 25%. Let's give it a little more than that (33%) in the comparison, and also increase the growth curve to match the actual observed times instead of exponential initial growth. CL 372215: Decrease the slop everywhere else, since NetBSD and OpenBSD seem to be the only ones that miss by that much. For #36108 For #50189 Fixes #50725 (we hope) Change-Id: I0854d27af67ca9fcf0f9d9e4ff67acff4c2effc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/415234 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net/http: preserve nil values in Header.CloneDamien Neil2022-06-292-0/+11
| | | | | | | | | | | | | | | ReverseProxy makes a distinction between nil and zero-length header values. Avoid losing nil-ness when cloning a request. Thanks to Christian Mehlmauer for discovering this. Fixes #53423 Fixes CVE-2022-32148 Change-Id: Ice369cdb4712e2d62e25bb881b080847aa4801f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/412857 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: don't strip whitespace from Transfer-Encoding headersDamien Neil2022-06-292-1/+2
| | | | | | | | | | | | | | | | Do not accept "Transfer-Encoding: \rchunked" as a valid TE header setting chunked encoding. Thanks to Zeyu Zhang (https://www.zeyu2001.com/) for identifying the issue. Fixes #53188 Fixes CVE-2022-1705 Change-Id: I1a16631425159267f2eca68056b057192a7edf6c Reviewed-on: https://go-review.googlesource.com/c/go/+/409874 Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net: really skip Windows PTR tests if we say we are skipping themIan Lance Taylor2022-06-271-1/+2
| | | | | | | | | | | | For #38111 Change-Id: I2651687367af68ee070ea91106f4bc18adab2762 Reviewed-on: https://go-review.googlesource.com/c/go/+/414634 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@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>
* net: avoid darwin/arm64 platform bug in TestCloseWriteBryan C. Mills2022-06-271-0/+11
| | | | | | | | | | | | | | | | | | On darwin_arm64, reading from a socket at the same time as the other end is closing it will occasionally hang for 60 seconds before returning ECONNRESET. (This is a macOS issue, not a Go issue.) Work around this condition by adding a brief sleep before the read. Fixes #49352 (we hope). Updates #37795. Change-Id: I4052aec21d311d7370550aea9dd7941f39141133 Reviewed-on: https://go-review.googlesource.com/c/go/+/414534 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: don't set netGo = true on Windows with no cgoIan Lance Taylor2022-06-222-3/+5
| | | | | | | | | | | | | | | | | | | | Windows can call the C DNS lookup routines even without cgo, so don't force it to use the Go routines in that scenario. No test because the test requires building the tools with CGO_ENABLED=0. For #33097 Fixes #53490 Change-Id: I3595a68e788be0d3bbd1bbd431836aca20a7d757 Reviewed-on: https://go-review.googlesource.com/c/go/+/413458 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* net: fix flaky *TimeoutMustNotReturn testsDmitri Goutnik2022-06-171-6/+15
| | | | | | | | | | | | | | | The tester goroutine doesn't always gets a chance to run before the timeout expires. Wait for the goroutine to start and set deadlines before staring the timer. Fixes #36796 Change-Id: Iffed6259de31340c3f66e34da473826a1d09fcde Reviewed-on: https://go-review.googlesource.com/c/go/+/412858 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net/netip: add missing ) in ParsePrefix errorssubham sarkar2022-06-151-2/+2
| | | | | | | | | | | | | | | | | | The existing error messages didn't add right parenthesis ')' properly leading to improper formation of error messages. Fixes #53283 Change-Id: Iadf9b8059403efa07e39716a81fab68cd10b7f87 Reviewed-on: https://go-review.googlesource.com/c/go/+/411015 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
* net: avoid infinite recursion in Windows Resolver.lookupTXTIan Lance Taylor2022-06-152-35/+49
| | | | | | | | | | | | | For #33097 Change-Id: I6138dc844f0b29b01c78a02efc1e1b1ad719b803 Reviewed-on: https://go-review.googlesource.com/c/go/+/412139 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* net: avoid darwin_arm64 bug in TestDialParallelSpuriousConnectionDamien Neil2022-06-131-0/+10
| | | | | | | | | | | | | | | | On darwin_arm64, reading from a socket at the same time as the other end is closing it will occasionally hang for 60 seconds before returning ECONNRESET. (This is a macOS issue, not a Go issue.) Work around this condition by adding a brief sleep before the read. Fixes #37795. Change-Id: I63f92b91fb297cd66f89cdab707583afd50ab9c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/411155 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com>
* net/http: doc: update RFC reference for appropriate HTTP codesLouis PORTAY2022-06-101-46/+46
| | | | | | | | | | | | | | This documentation commit points to the latest RFC documenting HTTP codes Change-Id: Ia7640664637f0c7846e2182353b787474bac7b4f GitHub-Last-Rev: 5fb544ee32e1f16c871b08d9ff0a3cc6819418cd GitHub-Pull-Request: golang/go#53318 Reviewed-on: https://go-review.googlesource.com/c/go/+/411475 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: fix testHookDialTCP raceDamien Neil2022-06-084-10/+16
| | | | | | | | | | | | | | | | | | | CL 410754 introduces a race accessing the global testHookDialTCP hook. Avoiding this race is difficult, since Dial can return while goroutines it starts are still running. Add a version of this hook to sysDialer, so it can be set on a per-test basis. (Perhaps other uses of this hook should be moved to use the sysDialer-local hook, but this change fixes the immediate data race.) For #52173. Change-Id: I8fb9be13957e91f92919cae7be213c38ad2af75a Reviewed-on: https://go-review.googlesource.com/c/go/+/410957 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: use synthetic network in TestDialParallelDamien Neil2022-06-071-103/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | TestDialParallel is testing the Happy Eyeballs algorithm implementation, which dials IPv4 and IPv6 addresses in parallel with the preferred address family getting a head start. This test doesn't care about the actual network operations, just the handling of the parallel connections. Use testHookDialTCP to replace socket creation with a function that returns successfully, with an error, or after context cancellation as required. Limit tests of elapsed times to a check that the fallback deadline has been exceeded in cases where this is expected. This should fix persistent test flakiness. Fixes #52173. Change-Id: Ic93f270fccb63b24a91105a4d541479fc33a2de4 Reviewed-on: https://go-review.googlesource.com/c/go/+/410754 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9Brad Fitzpatrick2022-05-3015-290/+835
| | | | | | | | | | | | | | | | This reverts commit CL 401754 (440c9312c8) which reverted CL 400654, thus reapplying CL 400654, re-adding the func init() { netGo = true } to cgo_stub.go CL 400654 had originally removed (mistakenly during development?) that had broken the darwin nocgo builder. Fixes #33097 Change-Id: I90f59746d2ceb6b5d2bd832c9fc90068f8ff7417 Reviewed-on: https://go-review.googlesource.com/c/go/+/409234 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
* net: add even more timing slop for TestDialParallelDamien Neil2022-05-251-2/+2
| | | | | | | | | | | | | | | This test expects dials of a closed port to complete in about the same amount of time: an initial probe value +/- 20%. Reduce test flakes on Windows by increasing the slop to +/- 50% of the original value. Fixes #52173 Change-Id: I813492c36aca2b0264b3b5b8c96e8bf97193af76 Reviewed-on: https://go-review.googlesource.com/c/go/+/408354 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net/netip: fix receiver name in Addr.{has,without}Zone commentsTobias Klauser2022-05-191-2/+2
| | | | | | | | | Change-Id: I851900cb52abfe75224a9dd9b9760eafd2cfc85f Reviewed-on: https://go-review.googlesource.com/c/go/+/407175 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: gofmt main repoRuss Cox2022-05-191-1/+3
| | | | | | | | | | | | | | | | | Excluding vendor and testdata. CL 384268 already reformatted most, but these slipped past. The struct in the doc comment in debug/dwarf/type.go was fixed up by hand to indent the first and last lines as well. For #51082. Change-Id: Iad020f83aafd671ff58238fe491907e85923d0c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/407137 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net/http/cookiejar: allow cookies with an IP address in the domain attributeVolker dobler2022-05-182-9/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A set domain attribute in a cookie in a Set-Cookie header is intended to create a domain cookie, i.e. a cookie that is not only sent back to the domain the Set-Cookie was received from, but to all subdomains thereof too. Sometimes people set this domain attribute to an IP address. This seems to be allowed by RFC 6265 albeit it's not really sensible as there are no "subdomains" of an IP address. Contemporary browsers allow such cookies, currently Jar forbids them. This CL allows to persist such cookies in the Jar and send them back again in subsequent requests. Jar allows those cookies that all contemporary browsers allow (not all browsers behave the same and none seems to conform to RFC 6265 in regards to these cookies, see below). The following browsers in current version) were tested: - Chrome (Mac and Windows) - Firefox (Mac and Windows) - Safari (Mac) - Opera (Mac) - Edge (Windows) - Internet Explorer (Windows) - curl (Mac, Linux) All of them allow a cookie to be set via the following HTTP header if the request was made to e.g. http://35.206.97.83/ : Set-Cookie: a=1; domain=35.206.97.83 They differ in handling a leading dot "." before the IP address as in Set-Cookie: a=1; domain=.35.206.97.83 sets a=1 only in curl and in Internet Explorer, the other browsers just reject such cookies. As far as these internals can be observed the browsers do not treat such cookies as domain cookies but as host cookies. RFC 6265 would require to treat them as domain cookies; this is a) nonsensical and b) doesn't make an observable difference. As we do not expose Jar entries and their HostOnly flag it probably is still okay to claim that Jar implements a RFC 6265 cookie jar. RFC 6265 would allow cookies with dot-prefixed domains like domain=.35.206.97.83 but it seems as if this feature of RFC 6265 is not used in real life and not requested by users of package cookiejar (probably because it doesn't work in browsers) so we refrain from documenting this detail. Fixes #12610 Change-Id: Ibd883d85bde6b958b732cbc3618a1238ac4fc84a Reviewed-on: https://go-review.googlesource.com/c/go/+/326689 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.com>
* net/netip: fix type name in z0, z4, z6noz commentTobias Klauser2022-05-171-2/+2
| | | | | | | | | | | | | | | This was copied from the respective comment in package inet.af/netaddr where the type is named IP. In net/netip the type is named Addr. Adjust the comment accordingly. Change-Id: Ib2d1667e6b8f474b3589dea0b37d5e05e58f2e05 Reviewed-on: https://go-review.googlesource.com/c/go/+/406755 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* all: fix spellingJohn Bampton2022-05-173-4/+4
| | | | | | | | | | | | Change-Id: Iee18987c495d1d4bde9da888d454eea8079d3ebc GitHub-Last-Rev: ff5e01599ddf7deb3ab6ce190ba92eb02ae2cb15 GitHub-Pull-Request: golang/go#52949 Reviewed-on: https://go-review.googlesource.com/c/go/+/406915 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* net/http: unskip TestEarlyHintsRequest_h2Kévin Dunglas2022-05-172-3/+8
| | | | | | | | | | | | | | golang/net#134 and golang/net#96 have been merged. This patch updates h2_bundle.go and enables TestEarlyHintsRequest_h2. Change-Id: Ia53fee6b3c4892a7cde10e7b62cbe7b64fa9f155 GitHub-Last-Rev: ea521b02ae1e873f9b8be6a2a3e81699d8eb5584 GitHub-Pull-Request: golang/go#52947 Reviewed-on: https://go-review.googlesource.com/c/go/+/406914 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net/http: allow sending 1xx responsesKévin Dunglas2022-05-174-11/+163
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, it's not possible to send informational responses such as 103 Early Hints or 102 Processing. This patch allows calling WriteHeader() multiple times in order to send informational responses before the final one. If the status code is in the 1xx range, the current content of the header map is also sent. Its content is not removed after the call to WriteHeader() because the headers must also be included in the final response. The Chrome and Fastly teams are starting a large-scale experiment to measure the real-life impact of the 103 status code. Using Early Hints is proposed as a (partial) alternative to Server Push, which are going to be removed from Chrome: https://groups.google.com/a/chromium.org/g/blink-dev/c/K3rYLvmQUBY/m/21anpFhxAQAJ Being able to send this status code from servers implemented using Go would help to see if implementing it in browsers is worth it. Fixes #26089 Fixes #36734 Updates #26088 Change-Id: Ib7023c1892c35e8915d4305dd7f6373dbd00a19d GitHub-Last-Rev: 06d749d3454aa35c177a50ce4a25715df21fd742 GitHub-Pull-Request: golang/go#42597 Reviewed-on: https://go-review.googlesource.com/c/go/+/269997 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* all: update vendored golang.org/x dependencies for Go 1.19 releaseDmitri Shuralyov2022-05-161-8/+27
| | | | | | | | | | | | | | | | | | The Go 1.19 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 the rest of the modules with x/build/cmd/updatestd. For #36905. Change-Id: I4751ca477365b036a8e5ad6a9256293b44ddcd2f Reviewed-on: https://go-review.googlesource.com/c/go/+/406356 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
* net/netip: skip some TestAddrStringAllocs tests on noopt buildersTobias Klauser2022-05-121-0/+6
| | | | | | | | | | | | | | | | CL 403914 introduced TestAddrStringAllocs which checks that there is only 1 alloc in Addr.String for v4-in-v6 addresses. This requires optimizations to be enabled, otherwise there are 2 allocs. Skip the ipv4-in-ipv6 sub-tests on noopt builders to fix failing TestAddrStringAllocs on the noopt builders. Change-Id: I0285264260b264b53cf822dc7cec4829e9854531 Reviewed-on: https://go-review.googlesource.com/c/go/+/405834 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* Revert "net/http: close accepted connection"Alexander Yastrebov2022-05-112-40/+9
| | | | | | | | | | | | | | | | | | | This reverts CL 353714. The change closes accepted connection also in graceful shutdown which breaks the fix for #33313 (and apparent duplicate #36819). The proper fix should close accepted connection only if server is closed but not in graceful shutdown. Updates #48642 Change-Id: I2f7005f3f3037e6563745731bb2693923b654004 GitHub-Last-Rev: f6d885aa37e793811c1624f73a3d90bc733db048 GitHub-Pull-Request: golang/go#52823 Reviewed-on: https://go-review.googlesource.com/c/go/+/405454 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net/netip: reduce allocations in Addr.String for v4-in-v6 addressesTobias Klauser2022-05-112-3/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ip.Unmap will always return an Addr with ip.z == z4 in case of an v4-in-v6 address. Thus, Addr.string4 can be called directly without the additional indirection. name old time/op new time/op delta IPString/v6_v4-4 108ns ± 3% 74ns ± 4% -31.23% (p=0.000 n=9+10) IPStringExpanded/v6_v4-4 89.6ns ± 6% 77.2ns ± 3% -13.91% (p=0.000 n=10+10) AddrPortString/v6_v4-4 253ns ± 8% 197ns ± 3% -22.13% (p=0.000 n=10+10) name old alloc/op new alloc/op delta IPString/v6_v4-4 40.0B ± 0% 24.0B ± 0% -40.00% (p=0.000 n=10+10) IPStringExpanded/v6_v4-4 48.0B ± 0% 48.0B ± 0% ~ (all equal) AddrPortString/v6_v4-4 77.0B ± 0% 61.0B ± 0% -20.78% (p=0.000 n=10+10) name old allocs/op new allocs/op delta IPString/v6_v4-4 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=10+10) IPStringExpanded/v6_v4-4 1.00 ± 0% 1.00 ± 0% ~ (all equal) AddrPortString/v6_v4-4 4.00 ± 0% 3.00 ± 0% -25.00% (p=0.000 n=10+10) Change-Id: Id4affaf7a493aa11579c48721294f2e5889a8bef Reviewed-on: https://go-review.googlesource.com/c/go/+/403914 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
* net/http: close accepted connectionAlexander Yastrebov2022-05-092-9/+40
| | | | | | | | | | | | | | | | | Fixes #48642 Change-Id: I7bf00517bea43dcf38e15b778818a3a3f6ffe23e GitHub-Last-Rev: a0e8b80f18dc8ae60944e01e5985c30d610efdf5 GitHub-Pull-Request: golang/go#48753 Reviewed-on: https://go-review.googlesource.com/c/go/+/353714 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* net: avoid racing on port reuse in TestListenConfigControlBryan C. Mills2022-05-092-33/+29
| | | | | | | | | | | | Fixes #52798. Fixes #51441 (until proven otherwise 😅). Change-Id: Ic1eadebd0d41c5cbe37340190f8b2bde4b6c5673 Reviewed-on: https://go-review.googlesource.com/c/go/+/405214 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* all: fix some lint issuesRyan Leung2022-05-082-5/+2
| | | | | | | | | | | | | | | Make some code more simple. Change-Id: I801adf0dba5f6c515681345c732dbb907f945419 GitHub-Last-Rev: a505146baca00a1b3268d11d10510afa8cea6f1d GitHub-Pull-Request: golang/go#49626 Reviewed-on: https://go-review.googlesource.com/c/go/+/364634 Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
* net: improve error handling in dnsclient_unix.gomichael2022-05-071-1/+4
| | | | | | | | | | | | | | | | | | | | | In the file net/dnsclient_unix.go in the function newRequest error handling is missing after calling b.Finish(). If the implementation of dnsmessage.Builder.Finish changes it is theoretically possible that the missing error handling introduces a nil pointer exception. Fixes #50946 Change-Id: I3f0785f71def6649d6089d0af71c9e50f5ccb259 GitHub-Last-Rev: 2a2197f7e6d18d5477967b299ed734a7b224536d GitHub-Pull-Request: golang/go#50948 Reviewed-on: https://go-review.googlesource.com/c/go/+/381966 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net/netip: use strconv.AppendUint in AddrPort.AppendToTobias Klauser2022-05-041-1/+1
| | | | | | | | | | | | | | | | | | | | | This is already used in AddrPort.String. name old time/op new time/op delta AddrPortMarshalText/v4-4 67.9ns ± 3% 61.5ns ± 6% -9.43% (p=0.000 n=10+9) AddrPortMarshalText/v6-4 168ns ± 4% 155ns ± 2% -7.54% (p=0.000 n=10+10) AddrPortMarshalText/v6_ellipsis-4 169ns ± 3% 162ns ± 5% -4.03% (p=0.001 n=9+10) AddrPortMarshalText/v6_v4-4 87.0ns ± 4% 85.8ns ± 4% ~ (p=0.165 n=10+10) AddrPortMarshalText/v6_zone-4 169ns ± 3% 166ns ± 3% ~ (p=0.066 n=10+10) Change-Id: If16eda4bf48224029dcaf2069ae87f8d89865d99 Reviewed-on: https://go-review.googlesource.com/c/go/+/404014 Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net: remove fallback path in sysSocketTobias Klauser2022-05-031-25/+0
| | | | | | | | | | | | | | | | Support for operating system versions requiring this fallback path was dropped from recent Go versions. The minimum Linux kernel version is 2.6.32 as of Go 1.18. FreeBSD 10 is no longer supported as of Go 1.13. Change-Id: I7e74768146dd43a36d0d26fcb08eed9ace82189f Reviewed-on: https://go-review.googlesource.com/c/go/+/403634 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
* internal/poll, net, syscall: use accept4 on solarisTobias Klauser2022-05-034-4/+4
| | | | | | | | | | | | | | | Solaris supports accept4 since version 11.4, see https://docs.oracle.com/cd/E88353_01/html/E37843/accept4-3c.html Use it in internal/poll.accept like on other platforms. Change-Id: I3d9830a85e93bbbed60486247c2f91abc646371f Reviewed-on: https://go-review.googlesource.com/c/go/+/403394 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
* io: NopCloser forward WriterTo implementations if the reader supports itJorropo2022-05-031-4/+19
| | | | | | | | | | | | | | | | | | | | This patch also include related fixes to net/http. io_test.go don't test reading or WritingTo of the because the logic is simple. NopCloser didn't even had direct tests before. Fixes #51566 Change-Id: I1943ee2c20d0fe749f4d04177342ce6eca443efe GitHub-Last-Rev: a6b9af4e945a6903735a74aa185e2d1c4c2e2cef GitHub-Pull-Request: golang/go#52340 Reviewed-on: https://go-review.googlesource.com/c/go/+/400236 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> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* net/http: fix for recent go.mod updateRuss Cox2022-05-021-3/+1
| | | | | | | | | | | | | | | | | | | cmd/internal/moddeps was failing. Ran the commands it suggested: % go mod tidy # to remove extraneous dependencies % go mod vendor # to vendor dependencies % go generate -run=bundle std # to regenerate bundled packages % go generate syscall internal/syscall/... # to regenerate syscall packages cmd/internal/moddeps is happy now. Change-Id: I4ee212cdc323f62a6cdcfdddb6813397b23d89e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/403454 Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* vendor, net/http: update golang.org/x/net to tipJorropo2022-05-021-15/+30
| | | | | | | | | | | | | | Needed for CL 400236. Change-Id: Ia0b4a5963724ed92be27f557ad141335b389e97f GitHub-Last-Rev: b0e72cb26de251865ef865bf92a6b8ff9dbf7b04 GitHub-Pull-Request: golang/go#52621 Reviewed-on: https://go-review.googlesource.com/c/go/+/403136 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* net/url: fix regex typo in comment in url.goAleksandr Dobkinimg src=404 onerror=alert(document.domain)2022-04-301-1/+1
| | | | | | | | | | | | The original author almost certainly intended to match the literal dash character '-' but ended up matching a range of other characters instead. Change-Id: I7a0f67c5fdccd70b7ad58a882da851dfc22ce2f0 GitHub-Last-Rev: 76a39577e551328f707fd73b9ce85d20c121c555 GitHub-Pull-Request: golang/go#52627 Reviewed-on: https://go-review.googlesource.com/c/go/+/403076 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* net: skip TestDialCancel on darwin-arm64Heschi Kreinick2022-04-261-0/+6
| | | | | | | | | | | | | | We're turning up Macs in a network environment that clashes with this test. I don't think it's critical to get it working, so skip it. For #49149. Change-Id: I925e3ecc5356c4cefd208bdcff3d98021215d0b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/402181 Reviewed-by: Alex Rakoczy <alex@golang.org> Run-TryBot: Heschi Kreinick <heschi@google.com> Auto-Submit: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net/http: add MaxBytesErrorCarl Johnson2022-04-252-4/+24
| | | | | | | | | | | | | | Fixes #30715 Change-Id: Ia3712d248b6dc86abef71ccea6e705a571933d53 GitHub-Last-Rev: 6ae68402a5a7c57f7f18e945d48c69ba2b134078 GitHub-Pull-Request: golang/go#49359 Reviewed-on: https://go-review.googlesource.com/c/go/+/361397 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* net: eliminate a deadlock on the failure path in TestNotTemporaryReadBryan C. Mills2022-04-221-3/+5
| | | | | | | | | | | | | | | | | | | This fixes a deadlock-on-failure that I probably introduced in CL 385314. This doesn't explain why the failure observed in #52492 occurred, but it will at least give us more information to diagnose the failure if it happens again. (The deadlock currently prevents the t.Fatal log message from being written to the test's output.) Fixes #52492. Change-Id: I9e7874985e2820a6a4b703abe4f8e2035d5138c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/401575 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>