浏览代码

client: defaultHTTPClient(): don't ignore transport errors

This function was suppressing errors coming from ConfigureTransport, with the
assumption that it will only be used with the Default configuration, and only return
errors for invalid / unsupported schemes (e.g., using "npipe" on a Linux environment);
https://github.com/moby/moby/blob/d109e429dd69bbfc2b575c11e66cbd98364a860b/vendor/github.com/docker/go-connections/sockets/sockets_unix.go#L27-L29

Those errors won't happen when the default is passed, so this is mostly theoretical.
Let's return the error instead (which should always be nil), just to be on the save
side, and to make sure that any other use of this function will return errors that
occurred, which may also be when parsing proxy environment variables;
https://github.com/moby/moby/blob/d109e429dd69bbfc2b575c11e66cbd98364a860b/vendor/github.com/docker/go-connections/sockets/sockets.go#L29

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 年之前
父节点
当前提交
722d477bc6
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      client/client.go

+ 4 - 1
client/client.go

@@ -167,7 +167,10 @@ func NewClientWithOpts(ops ...Opt) (*Client, error) {
 
 func defaultHTTPClient(hostURL *url.URL) (*http.Client, error) {
 	transport := &http.Transport{}
-	_ = sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host)
+	err := sockets.ConfigureTransport(transport, hostURL.Scheme, hostURL.Host)
+	if err != nil {
+		return nil, err
+	}
 	return &http.Client{
 		Transport:     transport,
 		CheckRedirect: CheckRedirect,