MCPcopy Index your code
hub / github.com/php/frankenphp / checkWriteHeaderCode

Function checkWriteHeaderCode

recorder_test.go:131–146  ·  view source on GitHub ↗
(code int)

Source from the content-addressed store, hash-verified

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

Callers 1

WriteHeaderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected