nethttp/response_recorder.go
func (res *ResponseRecorder) Write(contents []byte) (int, error) {
	if res.statusCode == 0 { // if not setted set it here
		res.WriteHeader(http.StatusOK)
	}
	res.chunks = append(res.chunks, contents)
	return res.underline.Write(contents)
}
func (res *ResponseRecorder) Write(contents []byte) (int, error) {
	if res.statusCode == 0 { // if not setted set it here
		res.WriteHeader(http.StatusOK)
	}
	res.chunks = append(res.chunks, contents)
	return res.underline.Write(contents)
}
func ( res * ResponseRecorder ) Write ( contents [ ] byte ) ( int , error ) { if res . statusCode == 0 { // if not setted set it here res . WriteHeader ( http . StatusOK ) } res . chunks = append ( res . chunks , contents ) return res . underline . Write ( contents ) }
// Write writes the data to the connection as part of an HTTP reply.
//
// If WriteHeader has not yet been called, Write calls
// WriteHeader(http.StatusOK) before writing the data. If the Header
// does not contain a Content-Type line, Write adds a Content-Type set
// to the result of passing the initial 512 bytes of written data to
// DetectContentType.
//
// Depending on the HTTP protocol version and the client, calling
// Write or WriteHeader may prevent future reads on the
// Request.Body. For HTTP/1.x requests, handlers should read any
// needed request body data before writing the response. Once the
// headers have been flushed (due to either an explicit Flusher.Flush
// call or writing enough data to trigger a flush), the request body
// may be unavailable. For HTTP/2 requests, the Go HTTP server permits
// handlers to continue to read the request body while concurrently
// writing the response. However, such behavior may not be supported
// by all HTTP/2 clients. Handlers should read before writing if
// possible to maximize compatibility.
Write writes the data to the connection as part of an HTTP reply . If WriteHeader has not yet been called Write calls WriteHeader ( http . StatusOK ) before writing the data . If the Header does not contain a Content - Type line Write adds a Content - Type set to the result of passing the initial 512 bytes of written data to DetectContentType . Depending on the HTTP protocol version and the client calling Write or WriteHeader may prevent future reads on the Request . Body . For HTTP / 1 . x requests handlers should read any needed request body data before writing the response . Once the headers have been flushed ( due to either an explicit Flusher . Flush call or writing enough data to trigger a flush ) the request body may be unavailable . For HTTP / 2 requests the Go HTTP server permits handlers to continue to read the request body while concurrently writing the response . However such behavior may not be supported by all HTTP / 2 clients . Handlers should read before writing if possible to maximize compatibility .