aboutsummaryrefslogtreecommitdiff
path: root/response.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-23 16:36:17 -0500
committerAdnan Maolood <[email protected]>2021-02-23 16:36:17 -0500
commit83c904913f1fe370c0793ce9d058560f68f462a6 (patch)
treea929f6b1b41eb7341ed3347c5204c21133244a46 /response.go
parentserver: Cancel context on IO errors (diff)
downloadgo-gemini-83c904913f1fe370c0793ce9d058560f68f462a6.tar.xz
go-gemini-83c904913f1fe370c0793ce9d058560f68f462a6.zip
response: Add Conn and TLS methods
Diffstat (limited to 'response.go')
-rw-r--r--response.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/response.go b/response.go
index 849e3f4..e091c1c 100644
--- a/response.go
+++ b/response.go
@@ -2,8 +2,10 @@ package gemini
import (
"bufio"
+ "crypto/tls"
"fmt"
"io"
+ "net"
"strconv"
)
@@ -36,6 +38,8 @@ type Response struct {
// a zero-length body. It is the caller's responsibility to
// close Body.
Body io.ReadCloser
+
+ conn net.Conn
}
// ReadResponse reads a Gemini response from the provided io.ReadCloser.
@@ -149,6 +153,21 @@ func (r *Response) Write(w io.Writer) error {
return nil
}
+// Conn returns the network connection on which the response was received.
+func (r *Response) Conn() net.Conn {
+ return r.conn
+}
+
+// TLS returns information about the TLS connection on which the
+// response was received.
+func (r *Response) TLS() *tls.ConnectionState {
+ if tlsConn, ok := r.conn.(*tls.Conn); ok {
+ state := tlsConn.ConnectionState()
+ return &state
+ }
+ return nil
+}
+
// A ResponseWriter interface is used by a Gemini handler to construct
// a Gemini response.
//