summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2023-08-07 12:53:21 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2023-08-07 12:53:21 -0600
commit431adc09805972196314b2b188904942cbe5dfee (patch)
tree50522eab43b05c38d1d7b2d12f6fb6e6149ee18a /modules
parenta8cc5d1a7d9d80e12ab895beaf4eaed34cc6bded (diff)
templates: Fix httpInclude (fix #5698)
Allowable during feature freeze because this is a simple, non-invasive bug fix only.
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/server.go12
1 files changed, 7 insertions, 5 deletions
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()
+ }
}
}