MCPcopy Index your code
hub / github.com/tailscale/tailscale / checkWriteHeaderCode

Function checkWriteHeaderCode

tempfork/httprec/httprec.go:121–136  ·  view source on GitHub ↗
(code int)

Source from the content-addressed store, hash-verified

119}
120
121func checkWriteHeaderCode(code int) {
122 // Issue 22880: require valid WriteHeader status codes.
123 // For now we only enforce that it's three digits.
124 // In the future we might block things over 599 (600 and above aren't defined
125 // at https://httpwg.org/specs/rfc7231.html#status.codes)
126 // and we might block under 200 (once we have more mature 1xx support).
127 // But for now any three digits.
128 //
129 // We used to send "HTTP/1.1 000 0" on the wire in responses but there's
130 // no equivalent bogus thing we can realistically send in HTTP/2,
131 // so we'll consistently panic instead and help people find their bugs
132 // early. (We can't return an error from WriteHeader even if we wanted to.)
133 if code < 100 || code > 999 {
134 panic(fmt.Sprintf("invalid WriteHeader code %v", code))
135 }
136}
137
138// WriteHeader implements [http.ResponseWriter].
139func (rw *ResponseRecorder) WriteHeader(code int) {

Callers 1

WriteHeaderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…