]> Cypherpunks repositories - gostls13.git/commit
net/http/httptest: guarantee ResponseRecorder.Result returns a non-nil body
authorJack <jackxbritton@gmail.com>
Thu, 19 Jul 2018 12:24:44 +0000 (12:24 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 20 Jul 2018 19:04:25 +0000 (19:04 +0000)
commit59699aa166b724cb9b7d3a2d3ba21c87bc7c376a
treec56442e824a459517446366fd53e686a8188465d
parentf4c787b6cf3a90c32ecf9f885d8c32c6a675050b
net/http/httptest: guarantee ResponseRecorder.Result returns a non-nil body

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>
src/net/http/httptest/recorder.go
src/net/http/httptest/recorder_test.go