@@ -414,24 +414,36 @@ func (a *BasicAuth) UnmarshalYAML(unmarshal func(interface{}) error) error {
414
414
// by net.Dialer.
415
415
type DialContextFunc func (context.Context , string , string ) (net.Conn , error )
416
416
417
+ // DialTLSContextFunc defines the signature of the DialContext() function implemented
418
+ // by tls.Dialer.
419
+ type DialTLSContextFunc func (context.Context , string , string ) (net.Conn , error )
420
+
417
421
type httpClientOptions struct {
418
- dialContextFunc DialContextFunc
419
- keepAlivesEnabled bool
420
- http2Enabled bool
421
- idleConnTimeout time.Duration
422
- userAgent string
422
+ dialContextFunc DialContextFunc
423
+ dialTLSContextFunc DialTLSContextFunc
424
+ keepAlivesEnabled bool
425
+ http2Enabled bool
426
+ idleConnTimeout time.Duration
427
+ userAgent string
423
428
}
424
429
425
430
// HTTPClientOption defines an option that can be applied to the HTTP client.
426
431
type HTTPClientOption func (options * httpClientOptions )
427
432
428
- // WithDialContextFunc allows you to override func gets used for the actual dialing. The default is `net.Dialer.DialContext`.
433
+ // WithDialContextFunc allows you to override the func that gets used for the actual dialing. The default is `net.Dialer.DialContext`.
429
434
func WithDialContextFunc (fn DialContextFunc ) HTTPClientOption {
430
435
return func (opts * httpClientOptions ) {
431
436
opts .dialContextFunc = fn
432
437
}
433
438
}
434
439
440
+ // WithDialTLSContextFunc allows you to override the func that gets used for the actual dialing. The default is `tls.Dialer.DialContext`.
441
+ func WithDialTLSContextFunc (fn DialTLSContextFunc ) HTTPClientOption {
442
+ return func (opts * httpClientOptions ) {
443
+ opts .dialTLSContextFunc = fn
444
+ }
445
+ }
446
+
435
447
// WithKeepAlivesDisabled allows to disable HTTP keepalive.
436
448
func WithKeepAlivesDisabled () HTTPClientOption {
437
449
return func (opts * httpClientOptions ) {
@@ -519,6 +531,7 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
519
531
TLSHandshakeTimeout : 10 * time .Second ,
520
532
ExpectContinueTimeout : 1 * time .Second ,
521
533
DialContext : dialContext ,
534
+ DialTLSContext : opts .dialTLSContextFunc ,
522
535
}
523
536
if opts .http2Enabled && cfg .EnableHTTP2 {
524
537
// HTTP/2 support is golang had many problematic cornercases where
0 commit comments