Skip to content

Commit 82b8a7d

Browse files
committed
chore: migrate h2c.NewHandler to http.Server.Protocols
Replace deprecated golang.org/x/net/http2/h2c (SA1019) with stdlib http.Server.Protocols + http.Server.HTTP2 (Go 1.24+). Drops the http2 and h2c imports for the http11 server.
1 parent 41718fe commit 82b8a7d

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

servers/http11/http.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import (
1515
"github.com/roadrunner-server/errors"
1616
"github.com/roadrunner-server/http/v6/config"
1717
"github.com/roadrunner-server/http/v6/middleware"
18-
"golang.org/x/net/http2"
19-
"golang.org/x/net/http2/h2c" //nolint:staticcheck // SA1019: h2c migration to http.Server.Protocols tracked separately
2018
)
2119

2220
type Server struct {
@@ -37,16 +35,19 @@ func NewHTTPServer(handler http.Handler, cfg *config.Config, errLog *log.Logger,
3735
}
3836

3937
if cfg.HTTP2Config != nil && cfg.HTTP2Config.H2C {
38+
proto := new(http.Protocols)
39+
proto.SetHTTP1(true)
40+
proto.SetUnencryptedHTTP2(true)
41+
4042
return &Server{
4143
log: log,
4244
redirect: redirect,
4345
redirectPort: redirectPort,
4446
address: cfg.Address,
4547
http: &http.Server{
46-
Handler: h2c.NewHandler(handler, &http2.Server{ //nolint:staticcheck // SA1019: see import note
47-
MaxConcurrentStreams: cfg.HTTP2Config.MaxConcurrentStreams,
48-
PermitProhibitedCipherSuites: false,
49-
}),
48+
Handler: handler,
49+
Protocols: proto,
50+
HTTP2: &http.HTTP2Config{MaxConcurrentStreams: int(cfg.HTTP2Config.MaxConcurrentStreams)},
5051
ReadTimeout: time.Minute * 5,
5152
WriteTimeout: time.Minute * 5,
5253
IdleTimeout: time.Hour,

0 commit comments

Comments
 (0)