diff options
| author | Adnan Maolood <[email protected]> | 2021-02-23 17:27:54 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-23 17:29:50 -0500 |
| commit | c688defefda1cd8ebdde1d9359469f5b8daaa343 (patch) | |
| tree | cbaefee6e30f7dd4b4663df082316713e01a8b75 /request.go | |
| parent | response: Add Conn and TLS methods (diff) | |
| download | go-gemini-c688defefda1cd8ebdde1d9359469f5b8daaa343.tar.xz go-gemini-c688defefda1cd8ebdde1d9359469f5b8daaa343.zip | |
request: Add Conn and TLS methods
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 33 |
1 files changed, 16 insertions, 17 deletions
@@ -23,9 +23,6 @@ type Request struct { // For international domain names, Host may be in Punycode or // Unicode form. Use golang.org/x/net/idna to convert it to // either format if needed. - // - // For server requests, Host specifies the host on which the URL - // is sought. Host string // For client requests, Certificate optionally specifies the @@ -33,20 +30,7 @@ type Request struct { // This field is ignored by the Gemini server. Certificate *tls.Certificate - // RemoteAddr allows Gemini servers and other software to record - // the network address that sent the request, usually for - // logging. This field is not filled in by ReadRequest. - // This field is ignored by the Gemini client. - RemoteAddr net.Addr - - // TLS allows Gemini servers and other software to record - // information about the TLS connection on which the request - // was received. This field is not filled in by ReadRequest. - // The Gemini server in this package sets the field for - // TLS-enabled connections before invoking a handler; - // otherwise it leaves the field nil. - // This field is ignored by the Gemini client. - TLS *tls.ConnectionState + conn net.Conn } // NewRequest returns a new request. @@ -111,3 +95,18 @@ func (r *Request) Write(w io.Writer) error { } return bw.Flush() } + +// Conn returns the network connection on which the request was received. +func (r *Request) Conn() net.Conn { + return r.conn +} + +// TLS returns information about the TLS connection on which the +// response was received. +func (r *Request) TLS() *tls.ConnectionState { + if tlsConn, ok := r.conn.(*tls.Conn); ok { + state := tlsConn.ConnectionState() + return &state + } + return nil +} |