Skip to content

Commit

Permalink
Fix host string passed to PerRPCCredentials (grpc#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
xinzhangx authored and menghanl committed Aug 17, 2017
1 parent 596a6ac commit 5d9b09e
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,18 +349,13 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
// Create an audience string only if needed.
if len(t.creds) > 0 || callHdr.Creds != nil {
// Construct URI required to get auth request metadata.
var port string
if pos := strings.LastIndex(t.target, ":"); pos != -1 {
// Omit port if it is the default one.
if t.target[pos+1:] != "443" {
port = ":" + t.target[pos+1:]
}
}
// Omit port if it is the default one.
host := strings.TrimSuffix(callHdr.Host, ":443")
pos := strings.LastIndex(callHdr.Method, "/")
if pos == -1 {
pos = len(callHdr.Method)
}
audience = "https://" + callHdr.Host + port + callHdr.Method[:pos]
audience = "https://" + host + callHdr.Method[:pos]
}
for _, c := range t.creds {
data, err := c.GetRequestMetadata(ctx, audience)
Expand Down

0 comments on commit 5d9b09e

Please sign in to comment.