aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-27 13:59:45 -0500
committerAdnan Maolood <[email protected]>2021-02-27 13:59:45 -0500
commita396ec77e480a88f1227215acc38033a48d2bb6e (patch)
tree6d7cc0878bc4872e5e41c74737db6f799a3fb2aa
parentserver: Disallow ServeConn usage after Shutdown (diff)
downloadgo-gemini-a396ec77e480a88f1227215acc38033a48d2bb6e.tar.xz
go-gemini-a396ec77e480a88f1227215acc38033a48d2bb6e.zip
request: Cache calls to TLS
-rw-r--r--request.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/request.go b/request.go
index f15d891..59dd004 100644
--- a/request.go
+++ b/request.go
@@ -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
}