diff options
| author | Adnan Maolood <[email protected]> | 2021-02-23 20:59:04 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-23 20:59:04 -0500 |
| commit | d35dd3d8676dba18986e2704316a77371bd4a002 (patch) | |
| tree | 34590f1801ced31ce5255855b4b6cbf2f996accc /response.go | |
| parent | request: Remove TLS and Conn methods (diff) | |
| download | go-gemini-d35dd3d8676dba18986e2704316a77371bd4a002.tar.xz go-gemini-d35dd3d8676dba18986e2704316a77371bd4a002.zip | |
ResponseWriter: Add TLS and Conn methods
Diffstat (limited to 'response.go')
| -rw-r--r-- | response.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/response.go b/response.go index abbc757..57807e7 100644 --- a/response.go +++ b/response.go @@ -126,6 +126,7 @@ type ResponseWriter struct { mediatype string wroteHeader bool bodyAllowed bool + conn net.Conn } // NewResponseWriter returns a ResponseWriter that uses the provided io.WriteCloser. @@ -207,3 +208,17 @@ func (w *ResponseWriter) Flush() error { func (w *ResponseWriter) Close() error { return w.closer.Close() } + +// Conn returns the underlying network connection. +func (w *ResponseWriter) Conn() net.Conn { + return w.conn +} + +// TLS returns information about the underlying TLS connection. +func (w *ResponseWriter) TLS() *tls.ConnectionState { + if tlsConn, ok := w.conn.(*tls.Conn); ok { + state := tlsConn.ConnectionState() + return &state + } + return nil +} |