headers: Support repeated WriteHeader if 1xx (fix #5074)

This commit is contained in:
Matthew Holt 2022-09-23 17:11:53 -06:00
parent eead00f54a
commit 7041970059
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -332,7 +332,10 @@ func (rww *responseWriterWrapper) WriteHeader(status int) {
if rww.wroteHeader { if rww.wroteHeader {
return return
} }
rww.wroteHeader = true // 1xx responses aren't final; just informational
if status < 100 || status > 199 {
rww.wroteHeader = true
}
if rww.require == nil || rww.require.Match(status, rww.ResponseWriterWrapper.Header()) { if rww.require == nil || rww.require.Match(status, rww.ResponseWriterWrapper.Header()) {
if rww.headerOps != nil { if rww.headerOps != nil {
rww.headerOps.ApplyTo(rww.ResponseWriterWrapper.Header(), rww.replacer) rww.headerOps.ApplyTo(rww.ResponseWriterWrapper.Header(), rww.replacer)