From d9d5e318c2701f0dfd1decf6f77566501d720d20 Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Sat, 14 Dec 2024 17:45:45 +0100 Subject: [PATCH] fix: allow multiple informational status (#961) Informational status in the range 100-199 may be sent multiple times, unlike statuses in the range 200-599. This follows usage in the stdlib: https://github.com/golang/go/blob/485ed2fa5b5e0b7067ef72a0f4bdc9ca12b77ed7/src/net/http/server.go#L1216 --- middleware/wrap_writer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/middleware/wrap_writer.go b/middleware/wrap_writer.go index bf270881..12d4faf0 100644 --- a/middleware/wrap_writer.go +++ b/middleware/wrap_writer.go @@ -81,7 +81,11 @@ type basicWriter struct { } func (b *basicWriter) WriteHeader(code int) { - if !b.wroteHeader { + if code >= 100 && code <= 199 && code != http.StatusSwitchingProtocols { + if !b.discard { + b.ResponseWriter.WriteHeader(code) + } + } else if !b.wroteHeader { b.code = code b.wroteHeader = true if !b.discard {