Skip to content

Commit

Permalink
[xds_interop_client_rpc_metadata] unarycall also checks hostname from…
Browse files Browse the repository at this point in the history
… response
  • Loading branch information
menghanl committed Jul 22, 2020
1 parent 7bb7e8a commit 5eff640
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions interop/xds/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,25 @@ func makeOneRPC(c testpb.TestServiceClient, cfg *rpcConfig) (*peer.Peer, *rpcInf
if len(cfg.md) != 0 {
ctx = metadata.NewOutgoingContext(ctx, cfg.md)
}
info := rpcInfo{typ: cfg.typ}

var err error
switch cfg.typ {
case unaryCall:
_, err = c.UnaryCall(ctx, &testpb.SimpleRequest{FillServerId: true}, grpc.Peer(&p), grpc.Header(&header))
var resp *testpb.SimpleResponse
resp, err = c.UnaryCall(ctx, &testpb.SimpleRequest{FillServerId: true}, grpc.Peer(&p), grpc.Header(&header))
// For UnaryCall, also read hostname from response, in case the server
// isn't updated to send headers.
if resp != nil {
info.hostname = resp.Hostname
}
case emptyCall:
_, err = c.EmptyCall(ctx, &testpb.Empty{}, grpc.Peer(&p), grpc.Header(&header))
}
if err != nil {
return nil, nil, err
}

info := rpcInfo{typ: cfg.typ}
hosts := header["hostname"]
if len(hosts) > 0 {
info.hostname = hosts[0]
Expand Down

0 comments on commit 5eff640

Please sign in to comment.