Commit 8e4ea2f5 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

net/http/httptest: add more docs on ResponseRecord fields

Fixes #16717

Change-Id: I7b6518609796a537437539c35461a18e9e6f207f
Reviewed-on: https://go-review.googlesource.com/32190Reviewed-by: 's avatarMartin Möhrmann <martisch@uos.de>
parent 31f50643
......@@ -15,9 +15,25 @@ 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
// 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment