client: encode the authority by default (#6318)

This commit is contained in:
Anirudh Ramachandra 2023-06-06 08:36:01 -07:00 committed by GitHub
parent c9d3ea5673
commit 68576b3c42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -1870,7 +1870,12 @@ func (cc *ClientConn) determineAuthority() error {
// the channel authority given the user's dial target. For resolvers
// which don't implement this interface, we will use the endpoint from
// "scheme://authority/endpoint" as the default authority.
cc.authority = endpoint
// Path escape the endpoint to handle use cases where the endpoint
// might not be a valid authority by default.
// For example an endpoint which has multiple paths like
// 'a/b/c', which is not a valid authority by default.
cc.authority = url.PathEscape(endpoint)
}
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
return nil

View File

@ -126,7 +126,7 @@ var authorityTests = []authorityTest{
name: "UnixPassthrough",
address: "/tmp/sock.sock",
target: "passthrough:///unix:///tmp/sock.sock",
authority: "unix:///tmp/sock.sock",
authority: "unix:%2F%2F%2Ftmp%2Fsock.sock",
dialTargetWant: "unix:///tmp/sock.sock",
},
{