request: Cache calls to TLS
This commit is contained in:
parent
21ad3a2ded
commit
a396ec77e4
11
request.go
11
request.go
|
@ -29,6 +29,7 @@ type Request struct {
|
||||||
Certificate *tls.Certificate
|
Certificate *tls.Certificate
|
||||||
|
|
||||||
conn net.Conn
|
conn net.Conn
|
||||||
|
tls *tls.ConnectionState
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRequest returns a new request.
|
// NewRequest returns a new request.
|
||||||
|
@ -101,9 +102,11 @@ func (r *Request) Conn() net.Conn {
|
||||||
// TLS returns information about the TLS connection on which the
|
// TLS returns information about the TLS connection on which the
|
||||||
// request was received.
|
// request was received.
|
||||||
func (r *Request) TLS() *tls.ConnectionState {
|
func (r *Request) TLS() *tls.ConnectionState {
|
||||||
if tlsConn, ok := r.conn.(*tls.Conn); ok {
|
if r.tls == nil {
|
||||||
state := tlsConn.ConnectionState()
|
if tlsConn, ok := r.conn.(*tls.Conn); ok {
|
||||||
return &state
|
state := tlsConn.ConnectionState()
|
||||||
|
r.tls = &state
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return r.tls
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user