Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http3: panic in ResponseWriter.WriteHeader for invalid status codes #3984

Merged
merged 5 commits into from
Jul 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion http3/response_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package http3
import (
"bufio"
"bytes"
"fmt"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -55,7 +56,12 @@ func (w *responseWriter) WriteHeader(status int) {
return
}

if status < 100 || status >= 200 {
// http status must be 3 digits
if status < 100 || status > 999 {
panic(fmt.Sprintf("invalid WriteHeader code %v", status))
}

if status >= 200 {
w.headerWritten = true
// Add Date header.
// This is what the standard library does.
Expand Down