fix handling for h2c

This commit is contained in:
WeidiDeng 2025-04-28 15:36:59 +08:00
parent 16e184af16
commit 6c1d6b06b4
No known key found for this signature in database
GPG Key ID: 25F87CE1741EC7CD
2 changed files with 9 additions and 0 deletions

View File

@ -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,
}

View File

@ -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