mirror of https://github.com/grpc/grpc-go.git
client: encode the authority by default (#6318)
This commit is contained in:
parent
c9d3ea5673
commit
68576b3c42
|
|
@ -1870,7 +1870,12 @@ func (cc *ClientConn) determineAuthority() error {
|
||||||
// the channel authority given the user's dial target. For resolvers
|
// the channel authority given the user's dial target. For resolvers
|
||||||
// which don't implement this interface, we will use the endpoint from
|
// which don't implement this interface, we will use the endpoint from
|
||||||
// "scheme://authority/endpoint" as the default authority.
|
// "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)
|
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ var authorityTests = []authorityTest{
|
||||||
name: "UnixPassthrough",
|
name: "UnixPassthrough",
|
||||||
address: "/tmp/sock.sock",
|
address: "/tmp/sock.sock",
|
||||||
target: "passthrough:///unix:///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",
|
dialTargetWant: "unix:///tmp/sock.sock",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue