aboutsummaryrefslogtreecommitdiff
path: root/request.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-24 08:24:47 -0500
committerAdnan Maolood <[email protected]>2021-02-24 08:24:49 -0500
commitde339490f43bd2ca169e3b82bbe44c106ed95bba (patch)
tree713fb6876fb45909735be4269f87bc763cf626ee /request.go
parentRemove ResponseWriter.Hijack method (diff)
downloadgo-gemini-de339490f43bd2ca169e3b82bbe44c106ed95bba.tar.xz
go-gemini-de339490f43bd2ca169e3b82bbe44c106ed95bba.zip
Move ResponseWriter Conn and TLS methods to Request
Diffstat (limited to 'request.go')
-rw-r--r--request.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/request.go b/request.go
index 3bfa3db..f15d891 100644
--- a/request.go
+++ b/request.go
@@ -4,6 +4,7 @@ import (
"bufio"
"crypto/tls"
"io"
+ "net"
"net/url"
)
@@ -26,6 +27,8 @@ type Request struct {
// TLS certificate to present to the other side of the connection.
// This field is ignored by the Gemini server.
Certificate *tls.Certificate
+
+ conn net.Conn
}
// NewRequest returns a new request.
@@ -89,3 +92,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
+// request was received.
+func (r *Request) TLS() *tls.ConnectionState {
+ if tlsConn, ok := r.conn.(*tls.Conn); ok {
+ state := tlsConn.ConnectionState()
+ return &state
+ }
+ return nil
+}