Skip to content

Commit

Permalink
allow sending 100 headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Mar 28, 2022
1 parent f8a62e7 commit 782fc6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions http2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2650,7 +2650,7 @@ func checkWriteHeaderCode(code int) {
// no equivalent bogus thing we can realistically send in HTTP/2,
// so we'll consistently panic instead and help people find their bugs
// early. (We can't return an error from WriteHeader even if we wanted to.)
if code <= 100 || code > 999 {
if code < 100 || code > 999 {
panic(fmt.Sprintf("invalid WriteHeader code %v", code))
}
}
Expand All @@ -2671,7 +2671,14 @@ func (rws *responseWriterState) writeHeader(code int) {
checkWriteHeaderCode(code)

// Handle informational headers, except 100 (Continue) which is handled automatically
if code > 100 && code < 200 {
if code >= 100 && code < 200 {
if code == 100 && rws.body.needsContinue {
rws.body.needsContinue = false
rws.conn.write100ContinueHeaders(rws.body.stream)

return
}

// Per RFC 8297 we must not clear the current header map
h := rws.handlerHeader

Expand Down

0 comments on commit 782fc6a

Please sign in to comment.