func newRespBadRequest() *http.Response { blk.Lock() defer blk.Unlock() r, err := http.DupResp(respErrBadRequest) if err != nil { panic("v") } return r }
func newRespNotFound() *http.Response { blk.Lock() defer blk.Unlock() r, err := http.DupResp(respErrNotFound) if err != nil { panic("v") } return r }
func newRespServiceUnavailable() *http.Response { blk.Lock() defer blk.Unlock() r, err := http.DupResp(respErrServiceUnavailable) if err != nil { panic("v") } return r }
func buildResp(html string) *http.Response { blk.Lock() defer blk.Unlock() resp, err := http.DupResp(respOK) if err != nil { panic("v") } resp.Body = http.StringToBody(html) resp.ContentLength = int64(len(html)) return resp }
// If bodylen is negative, chunked encoding is used. func buildRespFromBody(body io.ReadCloser, bodylen int64) *http.Response { blk.Lock() defer blk.Unlock() resp, err := http.DupResp(respOK) if err != nil { panic("v") } resp.Body = body if bodylen >= 0 { resp.ContentLength = bodylen } else { resp.TransferEncoding = []string{"chunked"} } return resp }