aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
AgeCommit message (Collapse)Author
2022-04-08all: consistently use US spelling of present participlesDaniel Martí
It has been agreed that we should prefer the US spelling of words like "canceling" over "cancelling"; for example, see https://go.dev/cl/14526. Fix a few occurrences of the "canceling" inconsistency, as well as: * signaling * tunneling * marshaling Change-Id: I99f3ba0a700a9f0292bc6c1b110af31dd05f1ff0 Reviewed-on: https://go-review.googlesource.com/c/go/+/398734 Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-06net/http: ignore ECONNRESET errors in TestTransportConcurrency on netbsdBryan C. Mills
The source of these errors is undiagnosed, but they have only been observed on netbsd builders (on a variety of architectures). Tested manually by injecting this code into the test's handler: if mrand.Intn(4) == 0 { if conn, _, err := w.(Hijacker).Hijack(); err == nil { conn.(*net.TCPConn).SetLinger(0) conn.Close() return } } and temporarily disabling the 'runtime.GOOS' part of the condition. For #52168. Change-Id: I10965803e5a0d493ac4a000575de8b5f0266989c Reviewed-on: https://go-review.googlesource.com/c/go/+/398635 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-05all: replace `` and '' with “ (U+201C) and ” (U+201D) in doc commentsRuss Cox
go/doc in all its forms applies this replacement when rendering the comments. We are considering formatting doc comments, including doing this replacement as part of the formatting. Apply it to our source files ahead of time. For #51082. Change-Id: Ifcc1f5861abb57c5d14e7d8c2102dfb31b7a3a19 Reviewed-on: https://go-review.googlesource.com/c/go/+/384262 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-04-01all: remove trailing blank doc comment linesRuss Cox
A future change to gofmt will rewrite // Doc comment. // func f() to // Doc comment. func f() Apply that change preemptively to all doc comments. For #51082. Change-Id: I4023e16cfb0729b64a8590f071cd92f17343081d Reviewed-on: https://go-review.googlesource.com/c/go/+/384259 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-01all: fix TODO comment hanging indentsRuss Cox
For whatever reason (perhaps some tool does this), a handful of comments, including some doc comments, have TODOs formatted like: // TODO(name): Text here and // more text aligned // under first text. In doc comments the second line turns into a <pre> block, which is undesirable in this context. Rewrite those to unindent, like this instead: // TODO(name): Text here and // more text aligned // at left column. For #51082. Change-Id: Ibf5145659a61ebf9496f016752a709a7656d2d4b Reviewed-on: https://go-review.googlesource.com/c/go/+/384258 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-04-01all: fix various doc comment formatting nitsRuss Cox
A run of lines that are indented with any number of spaces or tabs format as a <pre> block. This commit fixes various doc comments that format badly according to that (standard) rule. For example, consider: // - List item. // Second line. // - Another item. Because the - lines are unindented, this is actually two paragraphs separated by a one-line <pre> block. This CL rewrites it to: // - List item. // Second line. // - Another item. Today, that will format as a single <pre> block. In a future release, we hope to format it as a bulleted list. Various other minor fixes as well, all in preparation for reformatting. For #51082. Change-Id: I95cf06040d4186830e571cd50148be3bf8daf189 Reviewed-on: https://go-review.googlesource.com/c/go/+/384257 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-31net/http: handle 3xx responses with no LocationDamien Neil
RFC 7231 does not require that a 3xx response contain a Location header. When receiving such a response, just return it to the caller rather than treating it as an error. Fixes #49281. Change-Id: I66c06d81b0922016384a0f4ff32bf52e3a3d5983 Reviewed-on: https://go-review.googlesource.com/c/go/+/375354 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2022-03-25net/http/httptest: fix race in Server.CloseMaisem Ali
When run with race detector the test fails without the fix. Fixes #51799 Change-Id: I273adb6d3a2b1e0d606b9c27ab4c6a9aa4aa8064 GitHub-Last-Rev: a5ddd146a2a65f2e817eed5133449c79b3af2562 GitHub-Pull-Request: golang/go#51805 Reviewed-on: https://go-review.googlesource.com/c/go/+/393974 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2022-03-24net/http/httputil: ignore CloseNotify when a non-background context is presentDamien Neil
If the http.Request passed to ReverseProxy.ServeHTTP has a context with a non-nil Done channel, don't watch the ResponseWriter's CloseNotify channel. Avoids starting an extra background goroutine in the common case. Change-Id: I1328f3e02d3025caa0f446a2f20dfc14ef604c64 Reviewed-on: https://go-review.googlesource.com/c/go/+/376415 Trust: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Damien Neil <dneil@google.com>
2022-03-22net/http: fix nil body causing ParseMultipartForm to panichopehook
ParseMultipartForm relies on a valid multipartReader, if the request body is nil, the multipartReader should return an error. This way ParseMultipartForm can return an error instead of causing mr.ReadForm(maxMemory) to panic Fixes #48206 Change-Id: Ief906f2340c7ab29cacbd5f56892117202a0b911 Reviewed-on: https://go-review.googlesource.com/c/go/+/384454 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2022-03-20net/http: flesh out Request.SetBasicAuth docs a bitBrad Fitzpatrick
Clarify that username can't contain a colon. See https://go.dev/play/p/aM25UHC6n98 Change-Id: I342575107104cbcd28b1d3442c474adf93b7f03c Reviewed-on: https://go-review.googlesource.com/c/go/+/394115 Trust: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-17all: update vendored x dependencies for Go 1.19 development cycleHeschi Kreinick
Generated with x/build/cmd/updatestd. Updates #36905. Change-Id: I5d12dfc3b49c1476ce4b8d4cbeb35bd3d3443d26 Reviewed-on: https://go-review.googlesource.com/c/go/+/393369 Trust: Heschi Kreinick <heschi@google.com> Run-TryBot: Heschi Kreinick <heschi@google.com> Auto-Submit: Heschi Kreinick <heschi@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-08net/http/pprof: skip TestDeltaProfile on all arm and arm64 architecturesBryan C. Mills
Given that we have seen failures with the same failure mode on both openbsd/arm and android/arm64, it seems likely that the underlying bug affects at least all ARM-based architectures. It appears that either these architectures are not able to sample at the frequency expected by the test, or the samples are for some reason being dropped. For #50218 Change-Id: I42a6c8ecda57448f8068e8facb42a4a2cecbbb37 Reviewed-on: https://go-review.googlesource.com/c/go/+/383997 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-02-14net/http: deflake request-not-written pathDamien Neil
When we receive an error writing the first byte of a request to a reused connection, we retry the request on a new connection. Remove a flaky path which could cause the request to not be retried if persistConn.roundTrip reads the error caused by closing the connection before it reads the write error that caused the connection to be closed. Fixes #30938. Change-Id: Iafd99e3239cd9dba4a4c9ddd950a877ca9815e59 Reviewed-on: https://go-review.googlesource.com/c/go/+/379554 Trust: Bryan Mills <bcmills@google.com> Trust: Damien Neil <dneil@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-01-18net/http: skip TestClientTimeout_Headers_h{1,2} on windows/arm and windows/arm64Bryan C. Mills
This extends the skip added in CL 375635 to the "_Headers" variant of the test, since we have observed similar failures in that variant on the builders. For #43120 Change-Id: Ib1c97fbb776b576271629272f3194da77913a941 Reviewed-on: https://go-review.googlesource.com/c/go/+/379156 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2022-01-10net/http: map FS Open errors just like DirJonathan Amsterdam
When an http.FileServer is given a path like file1/file2 where file1 exists but file2 does not, the proper HTTP status should be NotFound. Some OSes return a "not a directory" error instead, so this must be mapped to NotFound. That mapping was already being done for the Dir FileSystem implementation, as discussed in #18984. But it wasn't for the FS implementation. This CL does the same mapping for FS, by generalizing the function that did it for Dir. Fixes #49552 Change-Id: I61d6aa8ef101158e9674707d44e653f5dedbd040 Reviewed-on: https://go-review.googlesource.com/c/go/+/376874 Trust: Jonathan Amsterdam <jba@google.com> Run-TryBot: Jonathan Amsterdam <jba@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-08net/http/internal/testcert: use FIPS-compliant certificateDamien Neil
Upgrade the test certificate from RSA 1024 (not FIPS-approved) to RSA 2048 (FIPS-approved), allowing tests to pass when the dev.boringcrypto branch FIPS-only mode is enabled. Fixes #48674. Change-Id: I613d2f8d0207bf3683fd0df256bf0167604996c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/353869 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2022-01-05net/http: skip TestClientTimeout_h{1,2} on windows/arm and windows/arm64Bryan C. Mills
These tests are empirically flaky on the windows/arm and windows/arm64 builders, with a consistent (but rare) failure mode. This change skips the test if that particular failure mode is encountered on those platforms; the skip can be removed if and when someone has the time to pin down the root cause. For #43120 Change-Id: Ie3a9a06bf47e3a907c7b07441acc1494a4631135 Reviewed-on: https://go-review.googlesource.com/c/go/+/375635 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-21net/http: fix link to ResponseWriter trailer exampleReilly Watson
The links to this example were using an underscore separator instead of a hyphen, and incorrect casing. Fixes #50279 Change-Id: I35d76a8a78cd708b7505ff1a70f7dacddaf43efd Reviewed-on: https://go-review.googlesource.com/c/go/+/373514 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2021-12-16net/http/pprof: skip TestDeltaProfile on openbsd/armBryan C. Mills
It is observed to be flaky on the only openbsd/arm builder. Skipping on that platform until someone can investigate. For #50218 Change-Id: Id3a6dc12b93b3cec67870d8d81bd608c4589c952 Reviewed-on: https://go-review.googlesource.com/c/go/+/372794 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13net/http: revert h2_bundle.go formatting change from CL 368254Bryan C. Mills
h2_bundle.go is automatically generated from x/net/http2. Any formatting changes within that file need to be first made upstream. This brings the contents of h2_bundle.go back in line with the upstream generator, fixing the cmd/internal/moddeps test that is currently failing on the longtest builders. For #49884 Change-Id: I5757240b77e250e0026b8a52a0e867e1578ec2d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/371297 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-13all: gofmt -w -r 'interface{} -> any' srcRuss Cox
And then revert the bootstrap cmd directories and certain testdata. And adjust tests as needed. Not reverting the changes in std that are bootstrapped, because some of those changes would appear in API docs, and we want to use any consistently. Instead, rewrite 'any' to 'interface{}' in cmd/dist for those directories when preparing the bootstrap copy. A few files changed as a result of running gofmt -w not because of interface{} -> any but because they hadn't been updated for the new //go:build lines. Fixes #49884. Change-Id: Ie8045cba995f65bd79c694ec77a1b3d1fe01bb09 Reviewed-on: https://go-review.googlesource.com/c/go/+/368254 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-09net/http: update bundled golang.org/x/net/http2Filippo Valsorda
Pull in security fix 2d13015 http2: cap the size of the server's canonical header cache and 0a0e4e1 http2: Fix handling of expect continue 04296fa http2: prioritize RST_STREAM frames in random write scheduler Fixes #50058 Fixes CVE-2021-44716 Change-Id: Ia40a2e52fa240e54a83b5ec7d8116cb6639ecbb9 Reviewed-on: https://go-review.googlesource.com/c/go/+/370579 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-12-07net/http: remove arbitrary timeout in TestServerHijackGetsBackgroundByte_bigBryan C. Mills
This test fails with "timeout" once per couple of months. It may be that the arbitrary timeout is too short, or it may be that the test is detecting a real bug (perhaps a deadlock) and reporting it without sufficient information to debug. Either way, the arbitrary timeout is doing only harm: either it is too short, or it is preventing us from getting a useful goroutine dump when the test inevitably times out. Fixes #35498 (hopefully). Change-Id: Ic6bbb1ef8df2c111b9888ba9903f58633e7cb95d Reviewed-on: https://go-review.googlesource.com/c/go/+/369854 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-11-30net/http: eliminate arbitrary timeout in TestClientWriteShutdownBryan C. Mills
This test occasionally hangs on the darwin-arm64-11_0-toothrot builder. When it does, it fails with the unhelpful error message "timeout" instead of a useful goroutine dump. This change eliminates the use of an arbitrary timeout channel, so that if (and probably when) the test hangs again we will get more useful logs to diagnose the root cause. For #49860 Change-Id: I23f6f1c81209f0b2dbe565e1dfb26b1b2eff0187 Reviewed-on: https://go-review.googlesource.com/c/go/+/367615 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-11-29vendor: update golang.org/x/net to tipIan Lance Taylor
This brings in a fix for OpenBSD that lets it correctly gather network interface information. For #42064 Change-Id: Ib88fd2f494bb2ee86fd2725d8375b2df1404c4ca Reviewed-on: https://go-review.googlesource.com/c/go/+/366756 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-11-12net/http: do not send Transfer-Encoding: identity in responsesDamien Neil
Server handlers may set a "Transfer-Encoding: identity" header on responses to disable chunking, but this header should not be sent on the wire. Fixes #49194. 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>
2021-11-12net/http: do not cancel request context on response body readDamien Neil
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). Fixes #49366. 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>
2021-11-09all: update vendored golang.org/x/{net,text} for Go 1.18 releaseDmitri Shuralyov
The Go 1.18 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 only the net, text modules. The next CL will update further ones. For #36905. Change-Id: I9a5ac3cca22da961cfd09f3202e01e1187d42bdd Reviewed-on: https://go-review.googlesource.com/c/go/+/362735 Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
2021-11-09net/http: add MaxBytesHandlerCarl Johnson
Fixes #39567 Change-Id: I226089b678a6a13d7ce69f360a23fc5bd297d550 GitHub-Last-Rev: 6435fd5881fc70a276d04df5a60440e365924b49 GitHub-Pull-Request: golang/go#48104 Reviewed-on: https://go-review.googlesource.com/c/go/+/346569 Trust: Damien Neil <dneil@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-11-08net/http: deflake TestTimeoutHandlerContextCanceledDamien Neil
Fixes #49448 Change-Id: Ie2acff7dedbca9bd1cc0b1b3dd0a01573c7befee Reviewed-on: https://go-review.googlesource.com/c/go/+/361920 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-07net/http: fix spelling in documentationjiahua wang
Change-Id: I8b0924300eafe27de98975512a78a6527a92e446 Reviewed-on: https://go-review.googlesource.com/c/go/+/354729 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Damien Neil <dneil@google.com>
2021-11-05net/http: adjust a substring which matches "uninteresting" goroutineNevkontakte
This change allows the check to pass unmodified under GopherJS, which stack traces are formatted differently (due to being generated by NodeJS). There are no other functions named `interestingGoroutines` in the standard library, so it's very unlikely to create false negatives, and will allow reduce the number of overlays GopherJS needs to maintain. Change-Id: I925594c6c313ca35805811f240c8528241950547 GitHub-Last-Rev: 26b32efb225c1ee85de0a51968c31b1a58d56f92 GitHub-Pull-Request: golang/go#49128 Reviewed-on: https://go-review.googlesource.com/c/go/+/358154 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Trust: Damien Neil <dneil@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05net/http: distinguish between timeouts and client hangups in TimeoutHandlerCharlie Getzen
Fixes #48948 Change-Id: I411e3be99c7979ae289fd937388aae63d81adb59 GitHub-Last-Rev: 14abd7e4d774ed5ef63aa0a69e80fbc8b5a5af26 GitHub-Pull-Request: golang/go#48993 Reviewed-on: https://go-review.googlesource.com/c/go/+/356009 Reviewed-by: Damien Neil <dneil@google.com> Trust: Damien Neil <dneil@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-11-05net/http: fix comment of writeRequestKeiichi Hirobe
Change-Id: I5ebfc6a89323cc086ea0e0b619370dc45da1f3a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/345437 Reviewed-by: Damien Neil <dneil@google.com> Trust: Damien Neil <dneil@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-11-04net/http: reduce TestClientTimeout_h{1,2} latencyBryan C. Mills
The test had been setting an arbitrary 200ms timeout to allow the server's handler to set up before timing out. That is not only potentially flaky on slow machines, but also typically much longer than necessary. Replace the hard-coded timeout with a much shorter initial timeout, and use exponential backoff to lengthen it if needed. This allows the test to be run about 20x faster in the typical case, which may make it easier to reproduce rare failure modes by running with a higher -count flag. For #43120 Change-Id: I1e0d0ec99d5a107fff56e3bcc7174d686ec582d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/361275 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-11-02net/http: deflake TestServerKeepAlivesEnabled_h{1,2}Damien Neil
This test assumes that two successive TCP connections will use different source ports. This does not appear to be a universally safe assumption. Rewrite the test to use httptrace to detect connection reuse instead. Fixes #46707 Change-Id: Iebfbdfdeb77a1e6663a0c654dc847cc270c5d54d Reviewed-on: https://go-review.googlesource.com/c/go/+/360854 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-02net/netip: add new IP address packageBrad Fitzpatrick
Co-authored-by: Alex Willmer <alex@moreati.org.uk> (GitHub @moreati) Co-authored-by: Alexander Yastrebov <yastrebov.alex@gmail.com> Co-authored-by: David Anderson <dave@natulte.net> (Tailscale CLA) Co-authored-by: David Crawshaw <crawshaw@tailscale.com> (Tailscale CLA) Co-authored-by: Dmytro Shynkevych <dmytro@tailscale.com> (Tailscale CLA) Co-authored-by: Elias Naur <mail@eliasnaur.com> Co-authored-by: Joe Tsai <joetsai@digital-static.net> (Tailscale CLA) Co-authored-by: Jonathan Yu <jawnsy@cpan.org> (GitHub @jawnsy) Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com> (Tailscale CLA) Co-authored-by: Maisem Ali <maisem@tailscale.com> (Tailscale CLA) Co-authored-by: Manuel Mendez (Go AUTHORS mmendez534@...) Co-authored-by: Matt Layher <mdlayher@gmail.com> Co-authored-by: Noah Treuhaft <noah.treuhaft@gmail.com> (GitHub @nwt) Co-authored-by: Stefan Majer <stefan.majer@gmail.com> Co-authored-by: Terin Stock <terinjokes@gmail.com> (Cloudflare CLA) Co-authored-by: Tobias Klauser <tklauser@distanz.ch> Fixes #46518 Change-Id: I0041f9e1115d61fa6e95fcf32b01d9faee708712 Reviewed-on: https://go-review.googlesource.com/c/go/+/339309 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-28net/http: restore generated // +build commentBryan C. Mills
The upstream cmd/bundle tool does not yet omit it, and the longtest builders test that the generated file is not modified. For #41184. Change-Id: Ib68f532139ed1436cbaf3a756f300fe60f520cab Reviewed-on: https://go-review.googlesource.com/c/go/+/359484 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-10-28all: go fix -fix=buildtag std cmd (except for bootstrap deps, vendor)Russ Cox
When these packages are released as part of Go 1.18, Go 1.16 will no longer be supported, so we can remove the +build tags in these files. Ran go fix -fix=buildtag std cmd and then reverted the bootstrapDirs as defined in src/cmd/dist/buildtool.go, which need to continue to build with Go 1.4 for now. Also reverted src/vendor and src/cmd/vendor, which will need to be updated in their own repos first. Manual changes in runtime/pprof/mprof_test.go to adjust line numbers. For #41184. Change-Id: Ic0f93f7091295b6abc76ed5cd6e6746e1280861e Reviewed-on: https://go-review.googlesource.com/c/go/+/344955 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-10-28net/http: guarantee that the Transport dial functions are respected in js/wasmNeil Alexander
The net/http package has a documented contract that if DialContext, DialDLSContext, Dial or DialTLS are specified in an instance of Transport, that they will be used to set up the connection. If they are not specified, then a reasonable fallback is made (e.g. using the net package). This is ordinarily true, except for when compiling for the js/wasm target, where the browser's Fetch API is preferred in all cases (except for when it is undefined/unavailable) and therefore the dial functions are all ignored. As a result, the http.Transport implementation under js/wasm doesn't meet that contract. This PR updates the RoundTrip behaviour of http.Transport so that if DialContext, DialTLSContext, Dial or DialTLS are specified, they are used as expected. The Fetch API will be used as a fallback if they are not specified. Fixes #27495 Change-Id: I88c6eb6ffdd077827b421d606f3e60ebdafd538f GitHub-Last-Rev: 948a0ed97ec4661f03cd346335f1d3d180f4c1ae GitHub-Pull-Request: golang/go#46923 Reviewed-on: https://go-review.googlesource.com/c/go/+/330852 Reviewed-by: Damien Neil <dneil@google.com> Trust: Damien Neil <dneil@google.com> Trust: Carlos Amedee <carlos@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-10-25net/http: correct Content-Length parsing for js/wasmCharlotte Brandhorst-Satzkorn
The Content-Length was incorrectly set to 0 for ill-formed and invalid values. In these cases, return an error. If the Content-Length header was omitted, it was incorrectly set to 0. In this case, set the Content-Length value to -1. Fixes #49108 Change-Id: I24fe9a31ed5b6ddb53f2b2bd10f2c84e428823e3 Reviewed-on: https://go-review.googlesource.com/c/go/+/358134 Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Trust: David Crawshaw <crawshaw@golang.org>
2021-10-20net/http/internal: return unexpected EOF on incomplete chunk readAlexander Yastrebov
Fixes #48861 Change-Id: I3f55bfbdc4f2cf5b33d1ab2d76e01335bb497c6f GitHub-Last-Rev: 0ecd790b87ddd31d0cf08e8f2726f918a2edd1fb GitHub-Pull-Request: golang/go#48903 Reviewed-on: https://go-review.googlesource.com/c/go/+/355029 Trust: Damien Neil <dneil@google.com> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-10-14net/http: also use Server.ReadHeaderTimeout for TLS handshake deadlineBrad Fitzpatrick
Fixes #48120 Change-Id: I72e89af8aaf3310e348d8ab639925ce0bf84204d Reviewed-on: https://go-review.googlesource.com/c/go/+/355870 Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-10-13net/http/httputil: allow MIME parameters when detecting SSE in ReverseProxyJames Harris
This change allows httputil.ReverseProxy to detect SSE (server-sent events) content when the response's Content-Type header includes MIME parameters, such as "text/event-stream;charset=utf-8". Prior to this change the value of the Content-Type header was compared directly to the literal "text/event-stream". This caused a false-negative which failed to set the FlushInterval correctly when MIME parameters were present. Change-Id: If8bb43efb78787b6519d7fe7599ca018a0da0023 GitHub-Last-Rev: 224518c5eb9686ee050c79f5f853ebacfdf6fc42 GitHub-Pull-Request: golang/go#48427 Reviewed-on: https://go-review.googlesource.com/c/go/+/350509 Trust: Alexander Rakoczy <alex@golang.org> Trust: Damien Neil <dneil@google.com> Run-TryBot: Alexander Rakoczy <alex@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2021-10-06net/http: add Cookie.Valid methodJohn Kelly
The (*http.Cookie).String method used by SetCookie will silently discard or sanitize any fields it deems invalid, making it difficult to tell whether a cookie will be sent as expected. This change introduces a new (*http.Cookie).Valid method which may be used to check if any cookie fields will be discarded or sanitized prior to calling (*http.Cookie).String. Fixes #46370 Change-Id: I2db80078de190d267a9c675a9717c8be8acc8704 Reviewed-on: https://go-review.googlesource.com/c/go/+/338590 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Cherry Mui <cherryyz@google.com> Trust: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2021-10-06all: update golang.org/x/net to pull in CL 353390Damien Neil
Fixes #48564. Fixes #23559. Change-Id: I8e0b646c4791d3a6fb17df1af0a7175b68ce8983 Reviewed-on: https://go-review.googlesource.com/c/go/+/353870 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>
2021-10-06all: use bytes.Cut, strings.CutRuss Cox
Many uses of Index/IndexByte/IndexRune/Split/SplitN can be written more clearly using the new Cut functions. Do that. Also rewrite to other functions if that's clearer. For #46336. Change-Id: I68d024716ace41a57a8bf74455c62279bde0f448 Reviewed-on: https://go-review.googlesource.com/c/go/+/351711 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>
2021-10-06net/http: parse HTTP version strings according to RFC 7230Damien Neil
RFC 2616 permits multiple digits in the major and minor numbers of an HTTP version: https://datatracker.ietf.org/doc/html/rfc2616#section-3.1 RFC 7230 obsoletes 2616 and tightens the specification to permit only a single digit in the major and minor number: https://datatracker.ietf.org/doc/html/rfc7230#section-2.6 Use the stricter definition. Also fix a bug which caused version numbers with a leading "+" to be accepted (e.g., "HTTP/1.+1".) Fixes #46587. Change-Id: Ic5923bb858e5ac402cfde486fba2c075e221553d Reviewed-on: https://go-review.googlesource.com/c/go/+/325874 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> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-02net/http/pprof: use "curl" instead of "wget" in usage exampleLeon Klingele
The "curl" binary is already used at several other places inside the code base, whereas this was the only occurrence of "wget". Change-Id: I2b9c5c353d08b3ba8289819b4a602c51f1ebd593 GitHub-Last-Rev: abf94855223c4ceac08dd0d18c5a2b97d1abcca9 GitHub-Pull-Request: golang/go#48718 Reviewed-on: https://go-review.googlesource.com/c/go/+/353401 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org>