aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/httptest
AgeCommit message (Collapse)Author
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>
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>
2021-06-10net/http: remove test-only private key from production binariesDamien Neil
The net/http/internal package contains a PEM-encoded private key used in tests. This key is initialized at init time, which prevents it from being stripped by the linker in non-test binaries. Move the certificate and key to a new net/http/internal/testcert package to ensure it is only included in binaries that reference it. Fixes #46677. Change-Id: Ie98bda529169314cc791063e7ce4d99ef99113c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/326771 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-04-14net/http/httptest: panic on non-3 digit (XXX) status code in ↵ian woolf
Recorder.WriteHeader This change conforms Recorder with net/http servers, to panic when a handler writes a non-3 digit XXX status code. Fixes #45353 Change-Id: Id5ed4af652e8c150ae86bf50402b800d935e2203 Reviewed-on: https://go-review.googlesource.com/c/go/+/308950 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com>
2021-03-25net/http/httptest: wait for user ConnState hooksDamien Neil
Ensure that user ConnState callbacks have completed before returning from (*httptest.Server).Close. Fixes: #37510 Fixes: #37505 Fixes: #45237 Change-Id: I8fe7baa089fbe4f3836bf6ae9767c7b1270d1331 Reviewed-on: https://go-review.googlesource.com/c/go/+/304829 Trust: Damien Neil <dneil@google.com> Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-05-31net/http: reject HTTP/1.1 Content-Length with sign in responsePaschalis Tsilias
Enforces section 14.13 of RFC 2616 so that Content-Length header values with a sign such as "+5" will be rejected. Updates #39017 Change-Id: Icce9f00d03c8475fe704b33f9bed9089ff8802f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/234817 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-05-06net/http: use ASCII space trimming throughoutFilippo Valsorda
Security hardening against HTTP request smuggling. Thank you to ZeddYu for reporting this issue. Change-Id: I98bd9f8ffe58360fc3bca9dc5d9a106773e55373 Reviewed-on: https://go-review.googlesource.com/c/go/+/231419 Reviewed-by: Katie Hockman <katie@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-18net/http/httptest: add EnableHTTP2 to ServerEmmanuel T Odeke
Adds a knob EnableHTTP2, that enables an unstarted Server and its respective client to speak HTTP/2, but only after StartTLS has been invoked. Fixes #34939 Change-Id: I287c568b8708a4d3c03e7d9eca7c323b8f4c65b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/201557 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-20net/http/httptest: update docs, remove old inaccurate sentenceBrad Fitzpatrick
The "After it is called, changing rw.Header will not affect rw.HeaderMap" claim predates the Result method which changed how the Recorder should be used. Fixes #32144 Fixes #32136 Change-Id: I95bdfa5ac489ce7b0202824bb5663f4da188e8a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/178058 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-04-24net/http: export Header.Clone, reduce its allocations, use it everywhereBrad Fitzpatrick
Fixes #29915 Change-Id: I6e6edf4f9a0e062211f74d120ae1a242bce1b274 Reviewed-on: https://go-review.googlesource.com/c/go/+/173658 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ingo Oeser <nightlyone@googlemail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-03-11all: move internal/x to vendor/golang.org/x and revendor using 'go mod vendor'Bryan C. Mills
This also updates the vendored-in versions of several packages: 'go mod vendor' selects a consistent version of each module, but we had previously vendored an ad-hoc selection of packages. Notably, x/crypto/hkdf was previously vendored in at a much newer commit than the rest of x/crypto. Bringing the rest of x/crypto up to that commit introduced an import of golang.org/x/sys/cpu, which broke the js/wasm build, requiring an upgrade of x/sys to pick up CL 165749. Updates #30228 Updates #30241 Updates #25822 Change-Id: I5b3dbc232b7e6a048a158cbd8d36137af1efb711 Reviewed-on: https://go-review.googlesource.com/c/go/+/164623 Reviewed-by: Filippo Valsorda <filippo@golang.org>
2018-12-14net/http/httptest: don't register a flag unless it looks like it's in useBrad Fitzpatrick
We shouldn't pollute people's flags with this debugging flag that was never really meant to be public. It's certainly not documented. So keep it for now, but don't register it unless it looks like it's in use (by looking at os.Args). Kinda gross, but less gross than before. Fixes #28619 Change-Id: I47498948a26a71ff36f9658a6d9dac73fd0a3016 Reviewed-on: https://go-review.googlesource.com/c/154217 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-11-29vendor/golang_org/x: move to internal/xBryan C. Mills
Packages in vendor/ directories have a "vendor/" path prefix in GOPATH mode, but intentionally do not in module mode. Since the import path is embedded in the compiled output, changing that path invalidates cache entries and causes cmd/go to try to rebuild (and reinstall) the vendored libraries, which will fail if the directory containing those libraries is read-only. If I understood correctly, this is the approach Russ suggested as an alternative to https://golang.org/cl/136138. Fixes #27285 Fixes #26988 Change-Id: I8a2507fa892b84cde0a803aaa79e460723da572b Reviewed-on: https://go-review.googlesource.com/c/147443 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2018-07-20net/http/httptest: guarantee ResponseRecorder.Result returns a non-nil bodyJack
The doc for ResponseRecorder.Result guarantees that the body of the returned http.Response will be non-nil, but this only holds true if the caller's body is non-nil. With this change, if the caller's body is nil then the returned response's body will be an empty io.ReadCloser. Fixes #26442 Change-Id: I3b2fe4a2541caf9997dbb8978bbaf1f58cd1f471 GitHub-Last-Rev: d802967d89e89c50077fb2d0d455163dcea0eb43 GitHub-Pull-Request: golang/go#26453 Reviewed-on: https://go-review.googlesource.com/124875 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-10net/http/httptest: deprecate ResponseRecorder.HeaderMapCaleb Spare
Users of this field are better off using Result instead. Fixes #25763. Change-Id: I4391afa6ed3873107628630adc1d409d77fb3f20 Reviewed-on: https://go-review.googlesource.com/117675 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-12net/http/httptest: table-test using named subtestsPierre Prinetti
Use Go 1.7 Run method of testing.T to run the table-driven tests into separate, named subtests. The behaviour of the tests is not modified. Change-Id: Ia88fa59a3534e79e3f0731e948b5f8a9919b339d Reviewed-on: https://go-review.googlesource.com/84478 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-16net/http: omit forbidden Trailer headers from responseDavid Url
Use the vendored ValidTrailerHeader function from x/net/http/httpguts to check Trailer headers according to RFC 7230. The previous implementation only omitted illegal Trailer headers defined in RFC 2616. This CL adds x/net/http/httpguts from CL 104042 (git rev a35a21de97) Fixes #23908 Change-Id: Ib2329a384040494093c18e209db9b62aaf86e921 Reviewed-on: https://go-review.googlesource.com/104075 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-26all: use strings.Builder instead of bytes.Buffer where appropriateBrad Fitzpatrick
I grepped for "bytes.Buffer" and "buf.String" and mostly ignored test files. I skipped a few on purpose and probably missed a few others, but otherwise I think this should be most of them. Updates #18990 Change-Id: I5a6ae4296b87b416d8da02d7bfaf981d8cc14774 Reviewed-on: https://go-review.googlesource.com/102479 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-02-20net/http: use RFC 723x as normative reference in docsDavid Url
Replace references to the obsoleted RFC 2616 with references to RFC 7230 through 7235, to avoid unnecessary confusion. Obvious inconsistencies are marked with todo comments. Updates #21974 Change-Id: I8fb4fcdd1333fc5193b93a2f09598f18c45e7a00 Reviewed-on: https://go-review.googlesource.com/94095 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-30net/http/httptest: allow creation of Server manuallyJoe Tsai
The Server struct has exported fields, which allows users to manually create a Server object without using using NewServer or NewTLSServer and directly call Start or StartTLS on their object. In order to ensure that manual creation of Server works, the NewUnstartedServer function should not initialize Server in any way that the user was not able to do themselves. For example, the setting of a unexported filed, client, is not something a user can do. Thus, rather than setting the client field in NewUnstartedServer, we lazily initialize it when Start or StartTLS is called. Otherwise, the Server logic can nil panic later when it assumes that this field has been initialized. Fixes #20871 Change-Id: I65c6a9f893ea963b0fbad0990b33af08007c1140 Reviewed-on: https://go-review.googlesource.com/47353 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-26net/http/httptest: close client connections in separate goroutinesYasha Bubnov
The existing implementation sequentially closes connection in the loop and until the previous client connections is not closed the next one would not be processed. Instead, the algorithm modified to spawn the function that closes single connection in a standalone goroutine, thus making at least a try to close it. Change-Id: Ib96b5b477f841926450d122b67f14f1a2da36ee1 Reviewed-on: https://go-review.googlesource.com/33614 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-23net/http/httptest: make ResponseRecorder.Result.Status match http.TransportBrad Fitzpatrick
Fixes #18438 Change-Id: I9599c1536d5e8bad7662b8ffa19e9b0746e27e60 Reviewed-on: https://go-review.googlesource.com/44000 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-27net/http/httptest: don't panic on Close of user-constructed Server valueBrad Fitzpatrick
If the user created an httptest.Server directly without using a constructor it won't have the new unexported 'client' field. So don't assume it's non-nil. Fixes #19729 Change-Id: Ie92e5da66cf4e7fb8d95f3ad0f4e3987d3ae8b77 Reviewed-on: https://go-review.googlesource.com/38710 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Kevin Burke <kev@inburke.com>
2017-03-08net/http: use httptest.Server Client in testsJohan Brandhorst
After merging https://go-review.googlesource.com/c/34639/, it was pointed out to me that a lot of tests under net/http could use the new functionality to simplify and unify testing. Using the httptest.Server provided Client removes the need to call CloseIdleConnections() on all Transports created, as it is automatically called on the Transport associated with the client when Server.Close() is called. Change the transport used by the non-TLS httptest.Server to a new *http.Transport rather than using http.DefaultTransport implicitly. The TLS version already used its own *http.Transport. This change is to prevent concurrency problems with using DefaultTransport implicitly across several httptest.Server's. Add tests to ensure the httptest.Server.Client().Transport RoundTripper interface is implemented by a *http.Transport, as is now assumed across large parts of net/http tests. Change-Id: I9f9d15f59d72893deead5678d314388718c91821 Reviewed-on: https://go-review.googlesource.com/37771 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-03net/http/httptest: add Client and Certificate methods to ServerJohan Brandhorst
Adds a function for easily accessing the x509.Certificate of a Server, if there is one. Also adds a helper function for getting a http.Client suitable for use with the server. This makes the steps required to test a httptest TLS server simpler. Fixes #18411 Change-Id: I2e78fe1e54e31bed9c641be2d9a099f698c7bbde Reviewed-on: https://go-review.googlesource.com/34639 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-29net/http/httptest: fix typo in doc commentMichal Bohuslávek
Change-Id: I89f276b32015882437e128814573343a4ca53569 Reviewed-on: https://go-review.googlesource.com/33615 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-28net/http, net/http/httptest: cross-reference the two NewRequest funcsBrad Fitzpatrick
Updates #18082 Change-Id: I2e65b115b809c1e1bf813f538989d1a1f96b2876 Reviewed-on: https://go-review.googlesource.com/33636 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-12net/http/httptest: remove workaround on Plan 9David du Colombier
This issue has been fixed in CL 31390. Change-Id: I0c2425fd33be878037d10d612a50116a7b693431 Reviewed-on: https://go-review.googlesource.com/33195 Run-TryBot: David du Colombier <0intro@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-01net/http, net/http/httptest: make http2's TrailerPrefix work for http1Brad Fitzpatrick
Go's http1 implementation originally had a mechanism to send HTTP trailers based on pre-declaring the trailer keys whose values you'd later let after the header was written. http2 copied the same mechanism, but it was found to be unsufficient for gRPC's wire protocol. A second trailer mechanism was added later (but only to http2) for handlers that want to send a trailer without knowing in advance they'd need to. Copy the same mechanism back to http1 and document it. Fixes #15754 Change-Id: I8c40d55e28b0e5b7087d3d1a904a392c56ee1f9b Reviewed-on: https://go-review.googlesource.com/32479 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-26net/http/httptest: doc tweaksBrad Fitzpatrick
From lost-in-flight comments on CL 32190. Change-Id: I2029cbac6d24b5944a796b359080011ec3a8da92 Reviewed-on: https://go-review.googlesource.com/32210 Reviewed-by: Caleb Spare <cespare@gmail.com> Reviewed-by: Martin Möhrmann <martisch@uos.de>
2016-10-26net/http/httptest: add more docs on ResponseRecord fieldsBrad Fitzpatrick
Fixes #16717 Change-Id: I7b6518609796a537437539c35461a18e9e6f207f Reviewed-on: https://go-review.googlesource.com/32190 Reviewed-by: Martin Möhrmann <martisch@uos.de>
2016-09-21net/http/httptest: fill ContentLength in recorded ResponseThomas de Zeeuw
This change fills the ContentLength field in the http.Response returned by ResponseRecorder.Result. Fixes #16952. Change-Id: I9c49b1bf83e3719b5275b03a43aff5033156637d Reviewed-on: https://go-review.googlesource.com/28302 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-09-01crypto/tls: add Config.CloneBrad Fitzpatrick
In Go 1.0, the Config struct consisted only of exported fields. In Go 1.1, it started to grow private, uncopyable fields (sync.Once, sync.Mutex, etc). Ever since, people have been writing their own private Config.Clone methods, or risking it and doing a language-level shallow copy and copying the unexported sync variables. Clean this up and export the Config.clone method as Config.Clone. This matches the convention of Template.Clone from text/template and html/template at least. Fixes #15771 Updates #16228 (needs update in x/net/http2 before fixed) Updates #16492 (not sure whether @agl wants to do more) Change-Id: I48c2825d4fef55a75d2f99640a7079c56fce39ca Reviewed-on: https://go-review.googlesource.com/28075 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-08-23net/http/httptest: updated example to use Result()Dhaivat Pandit
example for httptest.Recorder was inspecting Recoder directly. Using Result() to convert Recorder into a http.Response yields a much better user experience. Closes #16837 Change-Id: Id0e636c12cd6adb1ba11f89953ff2b0f43758cf3 Reviewed-on: https://go-review.googlesource.com/27495 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-06-27net/http/httptest: show usage of httptest.NewRequest in exampleKonstantin Shaposhnikov
Change ExampleResponseRecorder to use httptest.NewRequest instead of http.NewRequest. This makes the example shorter and shows how to use one more function from the httptest package. Change-Id: I3d35869bd0a4daf1c7551b649428bb2f2a45eba2 Reviewed-on: https://go-review.googlesource.com/24480 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-05-19net/http/httptest: restore historic ResponseRecorder.HeaderMap behaviorBrad Fitzpatrick
In Go versions 1 up to and including Go 1.6, ResponseRecorder.HeaderMap was both the map that handlers got access to, and was the map tests checked their results against. That did not mimic the behavior of the real HTTP server (Issue #8857), so HeaderMap was changed to be a snapshot at the first write in https://golang.org/cl/20047. But that broke cases where the Handler never did a write (#15560), so revert the behavior. Instead, introduce the ResponseWriter.Result method, returning an *http.Response. It subsumes ResponseWriter.Trailers which was added for Go 1.7 in CL 20047. Result().Header now contains the correct answer, and HeaderMap is unchanged in behavior from previous Go releases, so we don't break people's tests. People wanting the correct behavior can use ResponseWriter.Result. Fixes #15560 Updates #8857 Change-Id: I7ea9b56a6b843103784553d67f67847b5315b3d2 Reviewed-on: https://go-review.googlesource.com/23257 Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-08net/http: fixed trivial go vet warningsEmmanuel Odeke
Updates #15177 Change-Id: I748f025461f313b5b426821ead695f90d3011a6b Reviewed-on: https://go-review.googlesource.com/21677 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31net/http/httptest: clean up unnecessary goroutineBrad Fitzpatrick
Finishes cleanup which was too late to do when discovered during the Go 1.6 cycle. Fixes #14291 Change-Id: Idc69fadbba10baf246318a22b366709eff088a75 Reviewed-on: https://go-review.googlesource.com/21360 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-23net/http/httptest: add NewRequest helper for ease of testing handlersBrad Fitzpatrick
Fixes #14199 Change-Id: Ic9284023b663de3db1ca7b7b1e96eeab82ec0944 Reviewed-on: https://go-review.googlesource.com/21016 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-08net/http/httptest: record trailing headers in ResponseRecorderCaio Marcelo de Oliveira Filho
Trailers() returns the headers that were set by the handler after the headers were written "to the wire" (in this case HeaderMap) and that were also specified in a proper header called "Trailer". Neither HeaderMap or trailerMap (used for Trailers()) are manipulated by the handler code, instead a third stagingMap is given to the handler. This avoid a reference kept by handler to affect the recorded results. If a handler just modify the header but doesn't call any Write or Flush method from ResponseWriter (or Flusher) interface, HeaderMap will not be updated. In this case, calling Flush in the recorder is enough to get the HeaderMap filled. Fixes #14531. Fixes #8857. Change-Id: I42842341ec3e95c7b87d7e6f178c65cd03d63cc3 Reviewed-on: https://go-review.googlesource.com/20047 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-02net: fix vet warningsMohit Agarwal
Updates #11041 Change-Id: I12c20beab75d7981efe470eb418e4b58dc8eb066 Reviewed-on: https://go-review.googlesource.com/20002 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02all: single space after period.Brad Fitzpatrick
The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24all: fix typos and spellingMartin Möhrmann
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913 Reviewed-on: https://go-review.googlesource.com/19829 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23all: fix typosShawn Smith
Change-Id: I6035941df8b0de6aeaf6c05df7257bcf6e9191fe Reviewed-on: https://go-review.googlesource.com/19320 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-10net/http/httptest: make Server.CloseClientConnections wait for conns to closeBrad Fitzpatrick
httptest.Server was rewritten during Go 1.6, but CloseClientConnections was accidentally made async in the rewrite and not caught due to lack of tests. Restore the Go 1.5 behavior and add tests. Fixes #14290 Updates #14291 Change-Id: I14f01849066785053ccca2373931bc82d78c0a13 Reviewed-on: https://go-review.googlesource.com/19432 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-10net/http/httptest: don't crash in mime sniffing if HeaderMap is nilBrad Fitzpatrick
Fixes some failing Google tests when run under Go tip (1.6). Updates #12986 Change-Id: I0ca4d20f6103d10ea9464e45730085401336dada Reviewed-on: https://go-review.googlesource.com/17698 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Nodir Turakulov <nodir@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-04net/http: register HTTP/2 before listening in ListenAndServeBrad Fitzpatrick
Change-Id: Icf9b6802945051aa484fb9ebcce71704f5655474 Reviewed-on: https://go-review.googlesource.com/16630 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-27net/http/httptest: close conns in StateNew on Server closeBrad Fitzpatrick
This part got dropped when we were debating between two solutions in https://golang.org/cl/15151 Fixes #13032 Change-Id: I820b94f6c0c102ccf9342abf957328ea01f49a26 Reviewed-on: https://go-review.googlesource.com/16313 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>