caddyhttp: responseRecorder save status in all cases (#5049)

This commit is contained in:
WeidiDeng 2022-09-18 08:47:53 +08:00 committed by GitHub
parent 00beec2e34
commit c7a6bc5934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -170,9 +170,11 @@ func (rr *responseRecorder) WriteHeader(statusCode int) {
return return
} }
// save statusCode in case http middleware upgrading websocket
// connections by manually setting headers and writing status 101
rr.statusCode = statusCode
// 1xx responses aren't final; just informational // 1xx responses aren't final; just informational
if statusCode < 100 || statusCode > 199 { if statusCode < 100 || statusCode > 199 {
rr.statusCode = statusCode
rr.wroteHeader = true rr.wroteHeader = true
// decide whether we should buffer the response // decide whether we should buffer the response