Wire up Cause for most context cancels (#7538)

This commit is contained in:
Francis Lavoie 2026-03-04 19:14:52 -05:00 committed by GitHub
parent fbfb8fc517
commit 6e5e08cf58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 42 additions and 23 deletions

View file

@ -448,7 +448,7 @@ func (h *HTTPTransport) NewTransport(caddyCtx caddy.Context) (*http.Transport, e
// complete the handshake before returning the connection
if rt.TLSHandshakeTimeout != 0 {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(ctx, rt.TLSHandshakeTimeout)
ctx, cancel = context.WithTimeoutCause(ctx, rt.TLSHandshakeTimeout, fmt.Errorf("HTTP transport TLS handshake %ds timeout", int(rt.TLSHandshakeTimeout.Seconds())))
defer cancel()
}
err = tlsConn.HandshakeContext(ctx)