diff options
| author | Adnan Maolood <[email protected]> | 2021-02-27 13:59:45 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-27 13:59:45 -0500 |
| commit | a396ec77e480a88f1227215acc38033a48d2bb6e (patch) | |
| tree | 6d7cc0878bc4872e5e41c74737db6f799a3fb2aa /request.go | |
| parent | server: Disallow ServeConn usage after Shutdown (diff) | |
| download | go-gemini-a396ec77e480a88f1227215acc38033a48d2bb6e.tar.xz go-gemini-a396ec77e480a88f1227215acc38033a48d2bb6e.zip | |
request: Cache calls to TLS
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -29,6 +29,7 @@ type Request struct { Certificate *tls.Certificate conn net.Conn + tls *tls.ConnectionState } // 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 // request was received. func (r *Request) TLS() *tls.ConnectionState { - if tlsConn, ok := r.conn.(*tls.Conn); ok { - state := tlsConn.ConnectionState() - return &state + if r.tls == nil { + if tlsConn, ok := r.conn.(*tls.Conn); ok { + state := tlsConn.ConnectionState() + r.tls = &state + } } - return nil + return r.tls } |