Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 00:30 UTC
templates: Fix httpInclude (fix #5698)
Allowable during feature freeze because this is a simple, non-invasive bug fix only.
Matthew Holt committed
Aug 7, 2023 at 12:53 UTC
431adc09805972196314b2b188904942cbe5dfee
1 file changed
+7
-5
modules/caddyhttp/server.go
+7
-5
@@ -245,12 +245,14 @@ type Server struct {
245
// ServeHTTP is the entry point for all HTTP requests.
246
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
247
// 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.
249
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
+ }
256
}
257
}
258