1
0
mirror of https://github.com/golang/go synced 2024-11-26 15:46:54 -07:00

net/http: check for nil, nil return from DialContext as well as Dial

This commit is contained in:
fangguizhen 2022-12-23 01:15:41 +08:00
parent de6abd7889
commit fd9b0c4193

View File

@ -1173,7 +1173,11 @@ var zeroDialer net.Dialer
func (t *Transport) dial(ctx context.Context, network, addr string) (net.Conn, error) {
if t.DialContext != nil {
return t.DialContext(ctx, network, addr)
c, err := t.DialContext(ctx, network, addr)
if c == nil && err == nil {
err = errors.New("net/http: Transport.DialContext hook returned (nil, nil)")
}
return c, err
}
if t.Dial != nil {
c, err := t.Dial(network, addr)