MCPcopy Create free account
hub / github.com/devfeel/dotweb / WriteHeader

Method WriteHeader

response.go:86–94  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

84// WriteHeader(http.StatusOK). Thus explicit calls to WriteHeader are mainly
85// used to send error codes.
86func (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.
97func (r *Response) Write(code int, b []byte) (n int, err error) {

Callers 5

RedirectMethod · 0.95
SetStatusCodeMethod · 0.95
WriteMethod · 0.95
wrapRouterHandleMethod · 0.45
WriteHeaderMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected