WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit ccad206

Browse files
committed
sockets: configureUnixTransport, configureNpipeTransport: remove proto arg
These utilities are created for a specific proto ("unix", or "npipe"), so the protocol should not be passed as an arguments as it cannot be overridden. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 34239ab commit ccad206

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

sockets/sockets.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func ConfigureTransport(tr *http.Transport, proto, addr string) error {
3737
}
3838
switch proto {
3939
case "unix":
40-
return configureUnixTransport(tr, proto, addr)
40+
return configureUnixTransport(tr, addr)
4141
case "npipe":
42-
return configureNpipeTransport(tr, proto, addr)
42+
return configureNpipeTransport(tr, addr)
4343
default:
4444
tr.Proxy = http.ProxyFromEnvironment
4545
tr.DisableCompression = false
@@ -50,7 +50,7 @@ func ConfigureTransport(tr *http.Transport, proto, addr string) error {
5050
return nil
5151
}
5252

53-
func configureUnixTransport(tr *http.Transport, proto, addr string) error {
53+
func configureUnixTransport(tr *http.Transport, addr string) error {
5454
if len(addr) > maxUnixSocketPathSize {
5555
return fmt.Errorf("unix socket path %q is too long", addr)
5656
}
@@ -60,7 +60,7 @@ func configureUnixTransport(tr *http.Transport, proto, addr string) error {
6060
Timeout: defaultTimeout,
6161
}
6262
tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {
63-
return dialer.DialContext(ctx, proto, addr)
63+
return dialer.DialContext(ctx, "unix", addr)
6464
}
6565
return nil
6666
}

sockets/sockets_unix.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
package sockets
44

5-
import "net/http"
6-
7-
func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
5+
func configureNpipeTransport(any, string) error {
86
return ErrProtocolNotAvailable
97
}

sockets/sockets_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/Microsoft/go-winio"
99
)
1010

11-
func configureNpipeTransport(tr *http.Transport, proto, addr string) error {
11+
func configureNpipeTransport(tr *http.Transport, addr string) error {
1212
// No need for compression in local communications.
1313
tr.DisableCompression = true
1414
tr.DialContext = func(ctx context.Context, _, _ string) (net.Conn, error) {

0 commit comments

Comments
 (0)