aboutsummaryrefslogtreecommitdiff
path: root/src/net/http
AgeCommit message (Collapse)Author
2022-08-26net/http: mention io.Seeker requirement in FS documentationAlex Studer
Both FileServer and NewFileTransport can try to seek a file, specifically when MIME type sniffing is performed. This can be somewhat surprising to an implementer of an fs.FS, as their filesystem will appear to work until a user tries to access a file with an unrecognized extension (which requires type sniffing and therefore seeking). With FileServer, this results in a "seeker can't seek" message, which is not very clear for the developer. The issue arises because fs.FS does not require Seek, while http.FileSystem does. Therefore, this change adds a line to the documentation of net/http's adapter function mentioning the requirement. Change-Id: Ieb955b7a7f34e2be39dd696cb712513c70100b3a GitHub-Last-Rev: fddccdae36e04fcb87d78b3b03fa4658dbb7d83d GitHub-Pull-Request: golang/go#48781 Reviewed-on: https://go-review.googlesource.com/c/go/+/353874 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2022-08-26net/http: add errors.As support for x/net/http2.StreamErrorAkshay Shah
To make it easier to extract the HTTP/2 error code (if any) from net/http errors, implement an As method on the vendored copy of golang.org/x/net/http2.StreamError. The new As method lets users work with the vendored error type as though it were the x/net/http2 StreamError. Fixes #53896. Change-Id: Ib18eb428adc05a3c0e19a946ece936e2378e1c7c Reviewed-on: https://go-review.googlesource.com/c/go/+/425104 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> Reviewed-by: David Chase <drchase@google.com>
2022-08-24net/http: remove unused doneChanAlexander Yastrebov
The https://golang.org/cl/43230 removed use of `getDoneChan`. Change-Id: I33390c0e3aea6d98367363773ebe39d9c1f64ae9 GitHub-Last-Rev: fe1e4154eaad4e485acfe4272f27d63367144e47 GitHub-Pull-Request: golang/go#53172 Reviewed-on: https://go-review.googlesource.com/c/go/+/409538 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: hopehook <hopehook@qq.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-23net/http/httputil: do not duplicate 'Connection: close' headersMiguel Ángel Jimeno
Fixes #54616. Change-Id: I46f41bbccff7b49f26f60c1edf65acfd1701aed5 Reviewed-on: https://go-review.googlesource.com/c/go/+/425155 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2022-08-22net/http/cookiejar: remove duplicate words from commentsAbirdcfly
Change-Id: Id44f587199683fd8018865af1c2442f9f74e0dad GitHub-Last-Rev: 35b1ab88677586c79918d363f22e05bc0c3c6479 GitHub-Pull-Request: golang/go#54495 Reviewed-on: https://go-review.googlesource.com/c/go/+/424434 Reviewed-by: hopehook <hopehook@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: hopehook <hopehook@qq.com> Reviewed-by: Joedian Reid <joedian@golang.org>
2022-08-22net/http: skip Get flakes in TestClientTimeout tests on windows/arm4Bryan C. Mills
There is already a skip in case of a later failure in the same test on these platforms. Skip the failure if it occurs earlier too. For #43120. Change-Id: Id530370caa6a7df8cae593f6fdcb66871b86b125 Reviewed-on: https://go-review.googlesource.com/c/go/+/425096 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-08-18all: remove duplicate "the" words in commentsAbirdcfly
Following CL 424454, using command rg --multiline " the\s{1,}the " * rg --multiline " the\s{1,}//\s{1,}the " * all the words "the" that are repeated in comments are found. Change-Id: I60b769b98f04c927b4c228e10f37faf190964069 Reviewed-on: https://go-review.googlesource.com/c/go/+/423836 Auto-Submit: Filippo Valsorda <filippo@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Filippo Valsorda <filippo@golang.org>
2022-08-17net/http: return ErrNoCookie from Request.Cookie when name is ""muyizixiu
Request.Cookie(name string) will return the first cookie when cookie name is "". Since readCookies in file net/http/cookie.go at line 247 return all cookies when second parameter is a empty string. To fix it, Return ErrNoCookie from Request.Cookie(""), instead of the first cookie in the request. Fixes #53181 Change-Id: Ie623ca4c53da64ef7623a7863292a2d771f76832 GitHub-Last-Rev: 01098cd5dbcc8d65e9c0893e0586601584e5f8b9 GitHub-Pull-Request: golang/go#53183 Reviewed-on: https://go-review.googlesource.com/c/go/+/409754 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-08-16net/http/httputil: add ReverseProxy.RewriteDamien Neil
Add a new Rewrite hook to ReverseProxy, superseding the Director hook. Director does not distinguish between the inbound and outbound request, which makes it possible for headers added by Director to be inadvertently removed before forwarding if they are listed in the inbound request's Connection header. Rewrite accepts a value containing the inbound and outbound requests, with hop-by-hop headers already removed from the outbound request, avoiding this problem. ReverseProxy's appends the client IP to the inbound X-Forwarded-For header by default. Users must manually delete untrusted X-Forwarded-For values. When used with a Rewrite hook, ReverseProxy now strips X-Forwarded-* headers by default. NewSingleHostReverseProxy creates a proxy that does not rewrite the Host header of inbound requests. Changing this behavior is cumbersome, as it requires wrapping the Director function created by NewSingleHostReverseProxy. The Rewrite hook's ProxyRequest parameter provides a SetURL method that provides equivalent functionality to NewSingleHostReverseProxy, rewrites the Host header by default, and can be more easily extended with additional customizations. Fixes #28168. Fixes #50580. Fixes #53002. Change-Id: Ib84e2fdd1d52c610e3887af66f517d4a74e594d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/407214 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2022-08-15net/http: make Request.WithContext documentation less prescriptiveDamien Neil
WithContext makes a shallow copy of a Request, and Clone makes a deep copy. Both set the context of the new request. The distinction between the two is clear, and it doesn't seem useful or necessary to say that "it's rare to need WithContext". Also update a couple locations that mention WithContext to mention Clone as well. Fixes #53413. Change-Id: I89e6ddebd7d5ca6573e522fe48cd7f50cc645cdd Reviewed-on: https://go-review.googlesource.com/c/go/+/412778 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2022-08-15net/http: allow zero-valued Expires in Cookie.ValidAmit Saha
The value of Expires is only checked when a value is set. This fixes the bug that a cookie with a zero-valued Expire was considered invalid, even though Expires is an optional field. Fixes #52989 Change-Id: I206c50e9b6ea2744a92c74673d589ce2aaa62670 Reviewed-on: https://go-review.googlesource.com/c/go/+/407654 Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-15net/http: add Server.DisableOptionsHandler for custom handling of OPTIONS *Alexander Yastrebov
Fixes #41773 Change-Id: I432ad5410d5e3bb0aff3a6e0eea6906ab1b214e2 GitHub-Last-Rev: 57d1ee249dcdf46c54214d0636f235e5c62af213 GitHub-Pull-Request: golang/go#49014 Reviewed-on: https://go-review.googlesource.com/c/go/+/356410 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: hopehook <hopehook@qq.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-12net/http: add a test to verify form tempfiles are deletedDamien Neil
The HTTP/1 server deletes multipart form tempfiles after ServeHTTP returns, but the HTTP/2 server does not. Add a test to verify cleanup happens in both cases, temporarily disabled for the HTTP/2 path. For #20253 Updates #25965 Change-Id: Ib753f2761fe73b29321d9d4337dbb5090fd193c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/423194 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-08-12all: replace hand-rolled atomicBool types with atomic.BoolLudi Rehak
Two packages construct atomic booleans from atomic integers. Replace these implementations with the new atomic.Bool type. Indeed, these packages were the impetus for the new atomic.Bool type, having demonstrated a need to access boolean values atomically. Change-Id: I6a0314f8e7d660984a6daf36a62ed05a0eb74b2f Reviewed-on: https://go-review.googlesource.com/c/go/+/411400 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2022-08-12net/http/httputil: don't insert default User-Agent header in proxied requestsDamien Neil
When ReverseProxy forwards a request with no User-Agent header, leave the header in the forwarded request blank rather than inserting the default Go HTTP clent User-Agent. We already did this for NewSingleHostReverseProxy; generalize it to every ReverseProxy. Change-Id: Id81a230cb8d384acdfae190b78a4265d80720388 Reviewed-on: https://go-review.googlesource.com/c/go/+/407375 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-12net/http/httputil: add X-Forwarded-{Host,Proto} headers in ReverseProxyDamien Neil
X-Forwarded-Host contains the original request's host. X-Forwarded-Proto contains "http" or "https", depending on whether the original request was made on a TLS-secured connection. Setting either header to nil in Director disables adding the header, same as for X-Forwarded-For. Fixes #50465. Change-Id: If8ed1f48d83f8ea0389c53519bc7994cb53891db Reviewed-on: https://go-review.googlesource.com/c/go/+/407414 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-08-12net/http: trim cookie namesdarmiel
The current implementation ignores cookies where the cookie name starts or ends with a space. For example, name =value is ignored. I have come across pages that send cookies in this weird format. I tested with the latest versions of Firefox, Safari and Chrome, all of which accept cookies in this format. To do this, I remove leading and trailing spaces from the cookie name after cutting at '='. Change-Id: I8fd0c37a2113b6ce75712dd43607d1ea55e86c68 GitHub-Last-Rev: 368f50fcb4c7537b90249c3c497e61dc81038f6e GitHub-Pull-Request: golang/go#52121 Reviewed-on: https://go-review.googlesource.com/c/go/+/397734 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Damien Neil <dneil@google.com>
2022-08-10net/http/cgi: remove port from the CGI environment of variable SERVER_NAMEhopehook
The SERVER_NAME variable in the CGI environment should not contain the port, according to the section 4.1.14 of the RFC 3875. Fixes #53368. Change-Id: Ifeea70206878cf83bc0bda35cb514d0226bbcd8c Reviewed-on: https://go-review.googlesource.com/c/go/+/412434 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: xie cui <523516579@qq.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-08-09net/http: remove unused method needsSniffAbirdcfly
Change-Id: Ia8c67d148fc7e71cac8954ccce6fffb8a6f423df GitHub-Last-Rev: 9441b8f0c510a3a03dc22816e2616d57f1411965 GitHub-Pull-Request: golang/go#54036 Reviewed-on: https://go-review.googlesource.com/c/go/+/419322 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Javad Rajabzadeh <ja7ad@live.com> Reviewed-by: hopehook <hopehook@qq.com> Reviewed-by: 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-08-08net/http: change conn.curReq type to atomic.Pointer[response]Ludi Rehak
Use the newly added atomic.Pointer[T] type for atomically loading and storing type *T pointers. This has the advantage of avoiding runtime type assertions required by its predecessor, atomic.Value. To fix build failures uncovered by TryBots (caused by "panic: unaligned 64-bit atomic operation"), also change conn.curState to type atomic.Uint64 so that it is 64-bit aligned. Change-Id: I6024d12cd581adfdccc01be7eb0faa7482036614 Reviewed-on: https://go-review.googlesource.com/c/go/+/420901 Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-08-05all: update vendored golang.org/x/{net,tools} for Go 1.20 developmentDmitri Shuralyov
CL 421334 updated most of golang.org/x dependencies at the start of the Go 1.20 development cycle. This CL updates x/net and x/tools as well, now that go.dev/issue/54259 is resolved. For #36905. Updates #54259. Change-Id: Ie422b71cba060a4774076eebf3b499cda1150367 Reviewed-on: https://go-review.googlesource.com/c/go/+/421461 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-07-21net/http: remove accidental heading in Head documentationDmitri Shuralyov
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>
2022-07-18http: improve Get documentationminherz
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>
2022-07-12net/http: clarify that MaxBytesReader returns *MaxBytesErrorDamien Neil
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>
2022-07-11net/http: remove Content-Encoding in writeNotModifiedMitar
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>
2022-07-08net/http: wait for listeners to exit in Server.Close and ShutdownDamien Neil
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>
2022-07-01net/http: omit invalid header value from error messageAlexander Yastrebov
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>
2022-06-29net/http: preserve nil values in Header.CloneDamien Neil
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>
2022-06-29net/http: don't strip whitespace from Transfer-Encoding headersDamien Neil
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>
2022-06-10net/http: doc: update RFC reference for appropriate HTTP codesLouis PORTAY
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>
2022-05-18net/http/cookiejar: allow cookies with an IP address in the domain attributeVolker dobler
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>
2022-05-17all: fix spellingJohn Bampton
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>
2022-05-17net/http: unskip TestEarlyHintsRequest_h2Kévin Dunglas
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>
2022-05-17net/http: allow sending 1xx responsesKévin Dunglas
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>
2022-05-16all: update vendored golang.org/x dependencies for Go 1.19 releaseDmitri Shuralyov
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>
2022-05-11Revert "net/http: close accepted connection"Alexander Yastrebov
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>
2022-05-09net/http: close accepted connectionAlexander Yastrebov
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>
2022-05-08all: fix some lint issuesRyan Leung
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>
2022-05-03io: NopCloser forward WriterTo implementations if the reader supports itJorropo
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>
2022-05-02net/http: fix for recent go.mod updateRuss Cox
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>
2022-05-02vendor, net/http: update golang.org/x/net to tipJorropo
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>
2022-04-25net/http: add MaxBytesErrorCarl Johnson
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>
2022-04-20net/http: drop mimesniff for audio/basicSean Liao
The WHATWG Mime Sniffing Standard we follow dropped support for .snd / audio/basic. https://github.com/whatwg/mimesniff/issues/151 Change-Id: Iae1bd8b29063b06b5b3909a944e12ead5974a526 Reviewed-on: https://go-review.googlesource.com/c/go/+/400754 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Auto-Submit: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-04-20net/http: deflake TestTransportConnectionCloseOnRequestBrad Fitzpatrick
Fixes #52450 (hopefully) Change-Id: Ib723f8efb4a13af1b98c25cd02935425172d01e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/401314 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-04-18net/http: eliminate arbitrary timeouts in ↵Bryan C. Mills
TestServerRequestContextCancel_ConnClose These timeouts are empirically sometimes (but rarely) too short on slower builders, and at any rate if this test fails “for real” we'll want a goroutine dump in order to debug it anyway. A goroutine dump is exactly what we get if we let the test time out on its own. Fixes #52414. Change-Id: Id2dd3839977bd8a41f296d67d1cccbf068fd73f4 Reviewed-on: https://go-review.googlesource.com/c/go/+/400816 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>
2022-04-17net/http: correctly show error types in transfer testJorropo
actualReader and tc.expectedReader are reflect.Type instances, not the actual objects. Change-Id: I7c9cfa489e3297b94c603b62bad1ed84bd207057 GitHub-Last-Rev: d581402375aea0c911fef663ec7e89a24c4e5524 GitHub-Pull-Request: golang/go#52339 Reviewed-on: https://go-review.googlesource.com/c/go/+/400235 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2022-04-15net/http: optimize StatusText implementationJoão Penteado
The current implementation, although more succinct, relies on a runtime lookup to a "constant" unexported map (which also needs to be initialized at runtime). The proposed implementation is able to be optimized by the compiler at build-time, resulting in *much* more efficient instructions. Additionally, unused string literals may even be removed altogether from the generated binary in some cases. This change is fully backwards-compatible behavior-wise with the existing implementation. Change-Id: I36450320aacff5b322195820552f2831d4fecd52 GitHub-Last-Rev: e2058f132ef7a193529d4b0e84329ac93e5d1dcb GitHub-Pull-Request: golang/go#49811 Reviewed-on: https://go-review.googlesource.com/c/go/+/367201 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-04-15net/http: remove cloneURL call in WithContextBobby Powers
Fixes #52239 Change-Id: I08b75e613e3c976855e39d01a6757d94e4207bf8 Reviewed-on: https://go-review.googlesource.com/c/go/+/399155 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-11net/http/httptest: allow multiple fields be present in one Trailer fieldMaxime Soulé
Fixes #51761 Change-Id: Ibaa17076ba51b666e25333e78180b8c7c4c940ec Reviewed-on: https://go-review.googlesource.com/c/go/+/393616 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-04-11all: gofmt main repoRuss Cox
[This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>