From 431adc09805972196314b2b188904942cbe5dfee Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 7 Aug 2023 12:53:21 -0600 Subject: templates: Fix httpInclude (fix #5698) Allowable during feature freeze because this is a simple, non-invasive bug fix only. --- modules/caddyhttp/server.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/caddyhttp/server.go b/modules/caddyhttp/server.go index 69b02c7..b31e6e5 100644 --- a/modules/caddyhttp/server.go +++ b/modules/caddyhttp/server.go @@ -245,12 +245,14 @@ type Server struct { // ServeHTTP is the entry point for all HTTP requests. func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { // If there are listener wrappers that process tls connections but don't return a *tls.Conn, this field will be nil. - // Can be removed if https://github.com/golang/go/pull/56110 is ever merged. + // TODO: Can be removed if https://github.com/golang/go/pull/56110 is ever merged. if r.TLS == nil { - conn := r.Context().Value(ConnCtxKey).(net.Conn) - if csc, ok := conn.(connectionStateConn); ok { - r.TLS = new(tls.ConnectionState) - *r.TLS = csc.ConnectionState() + // not all requests have a conn (like virtual requests) - see #5698 + if conn, ok := r.Context().Value(ConnCtxKey).(net.Conn); ok { + if csc, ok := conn.(connectionStateConn); ok { + r.TLS = new(tls.ConnectionState) + *r.TLS = csc.ConnectionState() + } } } -- cgit v1.2.3