// writeResponse writes an HTTP response. func writeResponse(w xo.Writer, resp *heat.Response, method string) error { if resp.Body != nil { defer resp.Body.Close() } size, err := heat.ResponseBodySize(resp, method) if err != nil { return err } if err = heat.WriteResponseHeader(w, resp); err != nil { return err } if err = w.Flush(); err != nil { return err } if size != 0 { if err = heat.WriteBody(w, resp.Body, size); err != nil { return err } if err = w.Flush(); err != nil { return err } } return nil }
func scrubResponse(resp *heat.Response, method string) error { // Only ever send HTTP/1.1 responses. resp.Major = 1 resp.Minor = 1 // Work out the response body size. size, err := heat.ResponseBodySize(resp, method) if err != nil { return err } scrubHeaderFields(&resp.Fields, size) return nil }