Write writes the data to the connection as part of an HTTP reply.
(b []byte)
| 61 | |
| 62 | // Write writes the data to the connection as part of an HTTP reply. |
| 63 | func (r *Response) Write(b []byte) (n int, err error) { |
| 64 | if !r.Committed { |
| 65 | if r.Status == 0 { |
| 66 | r.Status = http.StatusOK |
| 67 | } |
| 68 | r.WriteHeader(r.Status) |
| 69 | } |
| 70 | n, err = r.ResponseWriter.Write(b) |
| 71 | r.Size += int64(n) |
| 72 | for _, fn := range r.afterFuncs { |
| 73 | fn() |
| 74 | } |
| 75 | return |
| 76 | } |
| 77 | |
| 78 | // Flush implements the http.Flusher interface to allow an HTTP handler to flush |
| 79 | // buffered data to the client. |