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.
(statusCode int)
| 234 | // Thus explicit calls to WriteHeader are mainly used to |
| 235 | // send error codes. |
| 236 | func (w *responseWriter) WriteHeader(statusCode int) { |
| 237 | w.statusCode = statusCode |
| 238 | } |
| 239 | |
| 240 | func (w *responseWriter) tryWriteHeader() { |
| 241 | if w.written == NoWritten { // before write, once. |
no outgoing calls