-
Brad Fitzpatrick authored
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/23257Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
0b806598