Skip to content

Commit 1115158

Browse files
committed
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
1 parent 7b8f350 commit 1115158

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

modules/caddyhttp/responsewriter.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ func (rr *responseRecorder) WriteHeader(statusCode int) {
154154
// connections by manually setting headers and writing status 101
155155
rr.statusCode = statusCode
156156

157+
// decide whether we should buffer the response
158+
if rr.shouldBuffer == nil {
159+
rr.stream = true
160+
} else {
161+
rr.stream = !rr.shouldBuffer(rr.statusCode, rr.ResponseWriterWrapper.Header())
162+
}
163+
157164
// 1xx responses aren't final; just informational
158165
if statusCode < 100 || statusCode > 199 {
159166
rr.wroteHeader = true
160-
161-
// decide whether we should buffer the response
162-
if rr.shouldBuffer == nil {
163-
rr.stream = true
164-
} else {
165-
rr.stream = !rr.shouldBuffer(rr.statusCode, rr.ResponseWriterWrapper.Header())
166-
}
167167
}
168168

169169
// if informational or not buffered, immediately write header

0 commit comments

Comments
 (0)