mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-24 02:02:26 -04:00
return a net.Conn that implements connectionStater if applicable
This commit is contained in:
parent
4c1922448b
commit
92ea784712
@ -46,18 +46,27 @@ func (h *http2Listener) Accept() (net.Conn, error) {
|
|||||||
|
|
||||||
// if both h1 and h2 are enabled, we don't need to check the preface
|
// if both h1 and h2 are enabled, we don't need to check the preface
|
||||||
if h.useH1 && h.useH2 {
|
if h.useH1 && h.useH2 {
|
||||||
return &http2Conn{
|
return conn, nil
|
||||||
idx: len(http2.ClientPreface),
|
|
||||||
Conn: conn,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// impossible both are false, either useH1 or useH2 must be true,
|
// impossible both are false, either useH1 or useH2 must be true,
|
||||||
// or else the listener wouldn't be created
|
// or else the listener wouldn't be created
|
||||||
return &http2Conn{
|
h2Conn := &http2Conn{
|
||||||
h2Expected: h.useH2,
|
h2Expected: h.useH2,
|
||||||
Conn: conn,
|
Conn: conn,
|
||||||
}, nil
|
}
|
||||||
|
if isConnectionStater {
|
||||||
|
return http2StateConn{h2Conn}, nil
|
||||||
|
}
|
||||||
|
return h2Conn, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type http2StateConn struct {
|
||||||
|
*http2Conn
|
||||||
|
}
|
||||||
|
|
||||||
|
func (conn http2StateConn) ConnectionState() tls.ConnectionState {
|
||||||
|
return conn.Conn.(connectionStater).ConnectionState()
|
||||||
}
|
}
|
||||||
|
|
||||||
type http2Conn struct {
|
type http2Conn struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user