Skip to content

Commit

Permalink
templates: Fix httpInclude (fix #5698)
Browse files Browse the repository at this point in the history
Allowable during feature freeze because this is a simple, non-invasive
bug fix only.
  • Loading branch information
mholt committed Aug 7, 2023
1 parent a8cc5d1 commit 431adc0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/caddyhttp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}

Expand Down

0 comments on commit 431adc0

Please sign in to comment.