Skip to content

Commit

Permalink
fix: allow multiple informational status
Browse files Browse the repository at this point in the history
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
  • Loading branch information
costela committed Dec 3, 2024
1 parent 6ceb498 commit 3ea3720
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions middleware/wrap_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ type basicWriter struct {
}

func (b *basicWriter) WriteHeader(code int) {
if code >= 100 && code <= 199 && code != http.StatusSwitchingProtocols {
b.ResponseWriter.WriteHeader(code)
return
}
if !b.wroteHeader {
b.code = code
b.wroteHeader = true
Expand Down

0 comments on commit 3ea3720

Please sign in to comment.