diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-10-26 22:34:40 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-10-26 22:45:13 +0000 |
| commit | 8e4ea2f5e8ee2b9c455adb329d96fb13cd3c64da (patch) | |
| tree | 0d1158fb5fe086af2f1d08dbe6b0826c1bd1dd2b /src | |
| parent | 31f50643c36b3d2a74cf4f8df3a943bbbc06dafe (diff) | |
| download | go-8e4ea2f5e8ee2b9c455adb329d96fb13cd3c64da.tar.xz | |
net/http/httptest: add more docs on ResponseRecord fields
Fixes #16717
Change-Id: I7b6518609796a537437539c35461a18e9e6f207f
Reviewed-on: https://go-review.googlesource.com/32190
Reviewed-by: Martin Möhrmann <martisch@uos.de>
Diffstat (limited to 'src')
| -rw-r--r-- | src/net/http/httptest/recorder.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/net/http/httptest/recorder.go b/src/net/http/httptest/recorder.go index bc99797b33..dd27c4dc63 100644 --- a/src/net/http/httptest/recorder.go +++ b/src/net/http/httptest/recorder.go @@ -15,10 +15,26 @@ import ( // ResponseRecorder is an implementation of http.ResponseWriter that // records its mutations for later inspection in tests. type ResponseRecorder struct { - Code int // the HTTP response code from WriteHeader - HeaderMap http.Header // the HTTP response headers - Body *bytes.Buffer // if non-nil, the bytes.Buffer to append written data to - Flushed bool + // Code is the HTTP response code set by WriteHeader. + // + // Note that if a Handler never calls WriteHeader or Write, + // this might end up being 0, rather than the implicit + // http.StatusOK. To get the implicit value, use the Result + // method. + Code int + + // HeaderMap contains the headers explicitly set by the Handler. + // + // To get the implicit headers set by the server (such as + // automatic Content-Type), use the Result method. + HeaderMap http.Header + + // Body is the buffer that a Handler's Write calls are sent to. + // If nil, the Writes are silently discard. + Body *bytes.Buffer + + // Flushed is whether the Handler called Flush. + Flushed bool result *http.Response // cache of Result's return value snapHeader http.Header // snapshot of HeaderMap at first Write |
