MCPcopy Create free account
hub / github.com/couchbase/cbft / checkWriteHeaderCode

Function checkWriteHeaderCode

cmd/cbft/timeout_handler.go:208–223  ·  view source on GitHub ↗
(code int)

Source from the content-addressed store, hash-verified

206}
207
208func checkWriteHeaderCode(code int) {
209 // Issue 22880: require valid WriteHeader status codes.
210 // For now we only enforce that it's three digits.
211 // In the future we might block things over 599 (600 and above aren't defined
212 // at https://httpwg.org/specs/rfc7231.html#status.codes)
213 // and we might block under 200 (once we have more mature 1xx support).
214 // But for now any three digits.
215 //
216 // We used to send "HTTP/1.1 000 0" on the wire in responses but there's
217 // no equivalent bogus thing we can realistically send in HTTP/2,
218 // so we'll consistently panic instead and help people find their bugs
219 // early. (We can't return an error from WriteHeader even if we wanted to.)
220 if code < 100 || code > 999 {
221 panic(fmt.Sprintf("invalid WriteHeader code %v", code))
222 }
223}

Callers 1

writeHeaderLockedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected