Skip to content

Commit fdf3cea

Browse files
committed
net/http: document ResponseWriter.WriteHeader more
Change-Id: I65209b90ed7c56d4c751b3e4b3ce1de52dae368c Reviewed-on: https://go-review.googlesource.com/82635 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 95fab85 commit fdf3cea

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/net/http/server.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,20 @@ type ResponseWriter interface {
132132
// possible to maximize compatibility.
133133
Write([]byte) (int, error)
134134

135-
// WriteHeader sends an HTTP response header with status code.
135+
// WriteHeader sends an HTTP response header with the provided
136+
// status code.
137+
//
136138
// If WriteHeader is not called explicitly, the first call to Write
137139
// will trigger an implicit WriteHeader(http.StatusOK).
138140
// Thus explicit calls to WriteHeader are mainly used to
139141
// send error codes.
140-
WriteHeader(int)
142+
//
143+
// The provided code must be a valid HTTP 1xx-5xx status code.
144+
// Only one header may be written. Go does not currently
145+
// support sending user-defined 1xx informational headers,
146+
// with the exception of 100-continue response header that the
147+
// Server sends automatically when the Request.Body is read.
148+
WriteHeader(statusCode int)
141149
}
142150

143151
// The Flusher interface is implemented by ResponseWriters that allow

0 commit comments

Comments
 (0)