From c695c839862ebafbb9aaf31976ea99a55bc85536 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 26 Nov 2015 18:55:26 +0200 Subject: [PATCH] Added RequestCtx.IsTLS, which may be used for determining whether the connection is encrypted --- server.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server.go b/server.go index ac6c108..0875a65 100644 --- a/server.go +++ b/server.go @@ -248,9 +248,9 @@ type HijackHandler func(c net.Conn) // The server skips calling the handler in the following cases: // // * 'Connection: close' header exists in either request or response. -// * Unexpected error during writing response to the connection. +// * Unexpected error during response writing to the connection. // -// The server no longer processes requests from hijacked connections. +// The server stops processing requests from hijacked connections. // Server limits such as Concurrency, ReadTimeout, WriteTimeout, etc. // aren't applied to hijacked connections. // @@ -266,6 +266,14 @@ func (ctx *RequestCtx) Hijack(handler HijackHandler) { ctx.hijackHandler = handler } +// IsTLS returns true if the underlying connection is tls.Conn. +// +// tls.Conn is an encrypted connection (aka SSL, HTTPS). +func (ctx *RequestCtx) IsTLS() bool { + _, ok := ctx.c.(*tls.Conn) + return ok +} + type firstByteReader struct { c net.Conn ch byte