mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
templates: Fix httpInclude (fix #5698)
Allowable during feature freeze because this is a simple, non-invasive bug fix only.
This commit is contained in:
parent
a8cc5d1a7d
commit
431adc0980
1 changed files with 7 additions and 5 deletions
|
@ -245,14 +245,16 @@ type Server struct {
|
||||||
// ServeHTTP is the entry point for all HTTP requests.
|
// ServeHTTP is the entry point for all HTTP requests.
|
||||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
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.
|
// 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 {
|
if r.TLS == nil {
|
||||||
conn := r.Context().Value(ConnCtxKey).(net.Conn)
|
// 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 {
|
if csc, ok := conn.(connectionStateConn); ok {
|
||||||
r.TLS = new(tls.ConnectionState)
|
r.TLS = new(tls.ConnectionState)
|
||||||
*r.TLS = csc.ConnectionState()
|
*r.TLS = csc.ConnectionState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
w.Header().Set("Server", "Caddy")
|
w.Header().Set("Server", "Caddy")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue