diff --git a/modules/caddyhttp/app.go b/modules/caddyhttp/app.go index a76da0413..850f43ec5 100644 --- a/modules/caddyhttp/app.go +++ b/modules/caddyhttp/app.go @@ -552,6 +552,7 @@ func (app *App) Start() error { // check if the connection is h2c ln = &http2Listener{ useTLS: useTLS, + useH2C: h2cok, Listener: ln, logger: app.logger, } diff --git a/modules/caddyhttp/http2listener.go b/modules/caddyhttp/http2listener.go index ddf049d4c..4dadf671f 100644 --- a/modules/caddyhttp/http2listener.go +++ b/modules/caddyhttp/http2listener.go @@ -23,6 +23,7 @@ type connectionStater interface { // wrapper authors will hopefully implement it. type http2Listener struct { useTLS bool + useH2C bool net.Listener logger *zap.Logger } @@ -52,6 +53,13 @@ func (h *http2Listener) Accept() (net.Conn, error) { }, nil } + if h.useH2C { + return &http2Conn{ + idx: len(http2.ClientPreface), + Conn: conn, + }, nil + } + return &http2Conn{ Conn: conn, }, nil