Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uri.Path instead of uri.Host for UNIX domain socket URLs #540

Merged
merged 2 commits into from Sep 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion netconn.go
Expand Up @@ -62,7 +62,17 @@ func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, heade
}
return conn, nil
case "unix":
conn, err := net.DialTimeout("unix", uri.Host, timeout)
var conn net.Conn
var err error

// this check is preserved for compatibility with older versions
// which used uri.Host only (it works for local paths, e.g. unix://socket.sock in current dir)
if len(uri.Host) > 0 {
conn, err = net.DialTimeout("unix", uri.Host, timeout)
} else {
conn, err = net.DialTimeout("unix", uri.Path, timeout)
}

if err != nil {
return nil, err
}
Expand Down