mirror of
https://github.com/caddyserver/caddy.git
synced 2025-03-09 07:29:03 -04:00
caddyhttp: ResponseRecorder sets stream regardless of 1xx
Fixes a panic where rr.stream is not true when it should be in the event of 1xx, because the buf is nil
This commit is contained in:
parent
7b8f3505e3
commit
1115158616
@ -154,16 +154,16 @@ func (rr *responseRecorder) WriteHeader(statusCode int) {
|
|||||||
// connections by manually setting headers and writing status 101
|
// connections by manually setting headers and writing status 101
|
||||||
rr.statusCode = statusCode
|
rr.statusCode = statusCode
|
||||||
|
|
||||||
|
// decide whether we should buffer the response
|
||||||
|
if rr.shouldBuffer == nil {
|
||||||
|
rr.stream = true
|
||||||
|
} else {
|
||||||
|
rr.stream = !rr.shouldBuffer(rr.statusCode, rr.ResponseWriterWrapper.Header())
|
||||||
|
}
|
||||||
|
|
||||||
// 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.wroteHeader = true
|
rr.wroteHeader = true
|
||||||
|
|
||||||
// decide whether we should buffer the response
|
|
||||||
if rr.shouldBuffer == nil {
|
|
||||||
rr.stream = true
|
|
||||||
} else {
|
|
||||||
rr.stream = !rr.shouldBuffer(rr.statusCode, rr.ResponseWriterWrapper.Header())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if informational or not buffered, immediately write header
|
// if informational or not buffered, immediately write header
|
||||||
|
Loading…
x
Reference in New Issue
Block a user