Commit 42fe2e1c authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http2: don't check WriteHeader status if we've already sent the header

Tests will be in net/http in a separate CL.

Updates golang/go#23010

Change-Id: I91a6875b9a59b33a3c669e73dd6632ac523eb9f6
Reviewed-on: https://go-review.googlesource.com/86255Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent d866cfc3
...@@ -2509,7 +2509,6 @@ func checkWriteHeaderCode(code int) { ...@@ -2509,7 +2509,6 @@ func checkWriteHeaderCode(code int) {
} }
func (w *responseWriter) WriteHeader(code int) { func (w *responseWriter) WriteHeader(code int) {
checkWriteHeaderCode(code)
rws := w.rws rws := w.rws
if rws == nil { if rws == nil {
panic("WriteHeader called after Handler finished") panic("WriteHeader called after Handler finished")
...@@ -2519,6 +2518,7 @@ func (w *responseWriter) WriteHeader(code int) { ...@@ -2519,6 +2518,7 @@ func (w *responseWriter) WriteHeader(code int) {
func (rws *responseWriterState) writeHeader(code int) { func (rws *responseWriterState) writeHeader(code int) {
if !rws.wroteHeader { if !rws.wroteHeader {
checkWriteHeaderCode(code)
rws.wroteHeader = true rws.wroteHeader = true
rws.status = code rws.status = code
if len(rws.handlerHeader) > 0 { if len(rws.handlerHeader) > 0 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment