Proposals Unofficial Go proposal tracker

Deprecate the h2c package in favor of net/http unencrypted HTTP/2

#72039 · x/net/http2/h2c · low impact · Implemented ·

The golang.org/x/net/http2/h2c package serves unencrypted HTTP/2 (h2c) connections. It is deprecated because Go 1.24's net/http supports unencrypted HTTP/2 directly, on both the client and the server.

To serve h2c, add UnencryptedHTTP2 to Server.Protocols. To make h2c requests to http:// URLs, set Transport.Protocols to include UnencryptedHTTP2 but not HTTP1.

var p http.Protocols
p.SetHTTP1(true)
p.SetUnencryptedHTTP2(true)
srv := &http.Server{Addr: ":8080", Handler: h, Protocols: &p}

net/http supports only the "prior knowledge" method, where the client starts speaking HTTP/2 right away. It does not support the Upgrade: h2c mechanism from HTTP/1.1, and there are no plans to add it. RFC 9113 deprecates that mechanism. The h2c package's implementation of it was buggy, untested, and read the whole first request into memory. After this change, no non-deprecated Go package supports h2c upgrade.

Proposal
#72039 by neild
Status
Implemented on Oct 5, 2026
Impact
low
Area
x/net/http2/h2c