proposal: x/net/http2/h2c: deprecate h2c package #72039
Labels
LibraryProposal
Issues describing a requested change to the Go standard library or x/ libraries, but not to a tool
Proposal
Milestone
Proposal Details
The golang.org/x/net/h2c package provides support for serving unencrypted HTTP/2 connections.
This package was originally created because we were reluctant to support unencrypted HTTP/2 in the standard library, or even in the golang.org/x/net/http2 package. See #14141 for some background.
Go 1.24 includes support for unencrypted HTTP/2 client and server connections. Setting
Server.Protocols
to a value which includes theUnencryptedHTTP2
protocol enables support for serving unencrypted HTTP/2 connections. SettingTransport.Protocols
to a value which includesUnencryptedHTTP2
and notHTTP1
causes the client to use unencrypted HTTP/2 for requests for http:// URLs.I propose that we deprecate the
golang.org/x/net/h2c
package.More details below.
RFC 7540 defines two mechanisms for starting an unencrypted HTTP/2 connection.
The first is a protocol upgrade (section 3.2): The client sends an HTTP/1.1 request with an "Upgrade: h2c" header and an "HTTP2-Settings" header containing its HTTP/2 settings. The server may respond to this with an 101 Switching Protocols response followed by converting the connection to HTTP/2.
The second is "with prior knowledge" (section 3.4): The client opens an unencrypted TCP connection and starts the HTTP/2 protocol on it.
RFC 9113 deprecates the protocol upgrade mechanism (section 3.1):
Go 1.24's net/http package includes support for HTTP/2 with prior knowledge. It does not include support for the deprecated protocol upgrade mechanism, and we have no plans to add such support.
The x/net/http2/h2c package only supports server connections. It supports both protocol upgrade and prior knowledge.
I am not aware of any supported way to make an unencrypted HTTP/2 connection with protocol upgrade with net/http. The h2c package's support for protocol upgrade has no test coverage. Until CL 407454, it was also quite buggy. (See that CL for details.)
Deprecating the h2c package will leave us without any non-deprecated support for protocol upgrade. I think that's fine:
The text was updated successfully, but these errors were encountered: