Skip to content

Commit

Permalink
fix: allow multiple informational status (#961)
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 authored Dec 14, 2024
1 parent 6ceb498 commit d9d5e31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion middleware/wrap_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit d9d5e31

Please sign in to comment.