summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWeidiDeng <weidi_deng@icloud.com>2022-09-18 08:47:53 +0800
committerGitHub <noreply@github.com>2022-09-17 18:47:53 -0600
commitc7a6bc59345ca4075cc8bf97bd80900d28d8e05d (patch)
tree8baf9ec63cf362ece176650660307732c87cdd7f
parent00beec2e34cbbc111c5f61058ee5b2b05c90ca8b (diff)
caddyhttp: responseRecorder save status in all cases (#5049)
-rw-r--r--modules/caddyhttp/responsewriter.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/caddyhttp/responsewriter.go b/modules/caddyhttp/responsewriter.go
index 4e2c8f0..d29f6a7 100644
--- a/modules/caddyhttp/responsewriter.go
+++ b/modules/caddyhttp/responsewriter.go
@@ -170,9 +170,11 @@ func (rr *responseRecorder) WriteHeader(statusCode int) {
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
if statusCode < 100 || statusCode > 199 {
- rr.statusCode = statusCode
rr.wroteHeader = true
// decide whether we should buffer the response