Skip to content

Commit ccfcbc5

Browse files
authored
Merge pull request #58 from PaulSD/master
Replace deprecated Transport.Dial with Transport.DialContext
2 parents 5b033ed + 61039d0 commit ccfcbc5

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

sockets/sockets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func ConfigureTransport(tr *http.Transport, proto, addr string) error {
3232
if err != nil {
3333
return err
3434
}
35-
tr.Dial = dialer.Dial
35+
tr.DialContext = dialer.DialContext
3636
}
3737
return nil
3838
}

sockets/sockets_unix.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ func configureUnixTransport(tr *http.Transport, proto, addr string) error {
1818
}
1919
// No need for compression in local communications.
2020
tr.DisableCompression = true
21-
tr.Dial = func(_, _ string) (net.Conn, error) {
22-
return net.DialTimeout(proto, addr, defaultTimeout)
21+
dialer := &net.Dialer{
22+
Timeout: defaultTimeout,
23+
}
24+
tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
25+
return dialer.DialContext(ctx, proto, addr)
2326
}
2427
return nil
2528
}

sockets/sockets_windows.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ func configureUnixTransport(tr *http.Transport, proto, addr string) error {
1515
func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
1616
// No need for compression in local communications.
1717
tr.DisableCompression = true
18-
tr.Dial = func(_, _ string) (net.Conn, error) {
18+
dialer := &net.Dialer{
19+
Timeout: defaultTimeout,
20+
}
21+
tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
22+
// DialPipeContext() has been added to winio:
23+
// https://github.com/Microsoft/go-winio/commit/5fdbdcc2ae1c7e1073157fa7cb34a15eab472e1d
24+
// However, a new version of winio with this commit has not been released yet.
25+
// Continue to use DialPipe() until DialPipeContext() becomes available.
26+
//return winio.DialPipeContext(ctx, addr)
1927
return DialPipe(addr, defaultTimeout)
2028
}
2129
return nil

0 commit comments

Comments
 (0)