WriteHeader sends an HTTP response header with status code. If WriteHeader is not called explicitly, the first call to Write will trigger an implicit WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly used to send error codes.
(code int)
| 84 | // WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly |
| 85 | // used to send error codes. |
| 86 | func (r *Response) WriteHeader(code int) error { |
| 87 | if r.committed { |
| 88 | return errors.New("response already set status") |
| 89 | } |
| 90 | r.Status = code |
| 91 | r.writer.WriteHeader(code) |
| 92 | r.committed = true |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | // Write writes the data to the connection as part of an HTTP reply. |
| 97 | func (r *Response) Write(code int, b []byte) (n int, err error) { |
no outgoing calls
no test coverage detected