func (r *Response) Write(buf []byte) (int, error) {
	if !r.wroteHeader.isTrue() {
		if r.status == 0 {
			r.status = 200
		}
		r.WriteHeader(0)
	}
	return r.rw.Write(buf)
}
Write writes the data to the connection as part of an HTTP reply.
package gear
import (
	"bufio"
	"net"
	"net/http"
	"regexp"
)
var misdirectedResponseBody []byte = []byte(`{"error":"MisdirectedRequest","message":"The request was directed at a server that is not able to produce a response."}`)
var defaultHeaderFilterReg = regexp.MustCompile(`(?i)^(accept|allow|retry-after|warning|vary|server|access-control-allow-|x-)`)
type Response struct {
	status      int     
	body        []byte  
	afterHooks  []func()
	endHooks    []func()
	ended       atomicBool  
	wroteHeader atomicBool
	handlerHeader http.Header
	w             http.ResponseWriter  
	rw            http.ResponseWriter  
}
func (r *Response) Get(key string) string {
	return r.handlerHeader.Get(key)
}
func (r *Response) Set(key, value string) {
	r.handlerHeader.Set(key, value)
}
func (r *Response) Add(key, value string) {
	r.handlerHeader.Add(key, value)
}
func (r *Response) Del(key string) {
	r.handlerHeader.Del(key)
}
func (r *Response) Vary(field string) {
	if field != "" && r.handlerHeader.Get(HeaderVary) != "*" {
		if field == "*" {
			r.handlerHeader.Set(HeaderVary, field)
		} else {
			r.handlerHeader.Add(HeaderVary, field)
		}
	}
}
func (r *Response) Status() int {
	return r.status
}
func (r *Response) Type() string {
	return r.Get(HeaderContentType)
}
func (r *Response) Body() []byte {
	return r.body
}
func (r *Response) ResetHeader(filterReg ...*regexp.Regexp) {
	reg := defaultHeaderFilterReg
	if len(filterReg) > 0 {
		reg = filterReg[0]
	}
	header := r.Header()
	for key := range header {
		if !reg.MatchString(key) {
			delete(header, key)
		}
	}
}
func (r *Response) Header() http.Header {
	return r.handlerHeader
}