Added RequestCtx.IsTLS, which may be used for determining whether the connection is encrypted

This commit is contained in:
Aliaksandr Valialkin
2015-11-26 18:55:26 +02:00
parent b31fd30964
commit c695c83986
+10 -2
View File
@@ -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