Skip to content

Commit 431adc0

Browse files
committed
templates: Fix httpInclude (fix caddyserver#5698)
Allowable during feature freeze because this is a simple, non-invasive bug fix only.
1 parent a8cc5d1 commit 431adc0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

modules/caddyhttp/server.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,14 @@ type Server struct {
245245
// ServeHTTP is the entry point for all HTTP requests.
246246
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
247247
// If there are listener wrappers that process tls connections but don't return a *tls.Conn, this field will be nil.
248-
// Can be removed if https://github.com/golang/go/pull/56110 is ever merged.
248+
// TODO: Can be removed if https://github.com/golang/go/pull/56110 is ever merged.
249249
if r.TLS == nil {
250-
conn := r.Context().Value(ConnCtxKey).(net.Conn)
251-
if csc, ok := conn.(connectionStateConn); ok {
252-
r.TLS = new(tls.ConnectionState)
253-
*r.TLS = csc.ConnectionState()
250+
// not all requests have a conn (like virtual requests) - see #5698
251+
if conn, ok := r.Context().Value(ConnCtxKey).(net.Conn); ok {
252+
if csc, ok := conn.(connectionStateConn); ok {
253+
r.TLS = new(tls.ConnectionState)
254+
*r.TLS = csc.ConnectionState()
255+
}
254256
}
255257
}
256258

0 commit comments

Comments
 (0)