]> Cypherpunks repositories - gostls13.git/commit
net/http: handle WriteHeader(101) as a non-informational header
authorDamien Neil <dneil@google.com>
Tue, 18 Apr 2023 15:50:02 +0000 (08:50 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 15 May 2023 17:35:28 +0000 (17:35 +0000)
commit268d2f7cf2217447e0995597384a0bcd29e0b638
treef7c0f69c566a4170c89c33b213af56074edeb57c
parent949d0f4f99c15541d7cd43f3e9812fb7ac9c73db
net/http: handle WriteHeader(101) as a non-informational header

Prior to Go 1.19 adding support for sending 1xx informational headers
with ResponseWriter.WriteHeader, WriteHeader(101) would send a 101
status and disable further writes to the response. This behavior
was not documented, but is intentional: Writing to the response
body explicitly checks to see if a 101 status has been sent before
writing.

Restore the pre-1.19 behavior when writing a 101 Switching Protocols
header: The header is sent, no subsequent headers are sent, and
subsequent writes to the response body fail.

For #59564

Change-Id: I72c116f88405b1ef5067b510f8c7cff0b36951ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/485775
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/net/http/serve_test.go
src/net/http/server.go