check for nil-ness of Dialer.TLSClientConfig before attempting to run the check

This commit is contained in:
Chan Kang 2022-06-12 00:51:51 -04:00
parent 464f255e78
commit a410921e1d
1 changed files with 9 additions and 7 deletions

View File

@ -186,13 +186,15 @@ func (d *Dialer) DialContext(ctx context.Context, urlStr string, requestHeader h
return nil, nil, errMalformedURL
}
for _, proto := range d.TLSClientConfig.NextProtos {
if proto != "http/1.1" {
return nil, nil, fmt.Errorf(
`protocol %q was given but is not supported;
sharing tls.Config with net/http Transport can cause this error`,
proto,
)
if d.TLSClientConfig != nil {
for _, proto := range d.TLSClientConfig.NextProtos {
if proto != "http/1.1" {
return nil, nil, fmt.Errorf(
`protocol %q was given but is not supported;
sharing tls.Config with net/http Transport can cause this error`,
proto,
)
}
}
}