Separate incoming and outgoing metadata in context

This will prevent the incoming RPCs' metadata from appearing in outgoing RPCs
unless it is explicitly copied, e.g.:

incomingMD, ok := metadata.FromContext(ctx)
if ok {
  ctx = metadata.NewContext(ctx, incomingMD)
}

Fixes #1148
This commit is contained in:
dfawley
2017-04-07 11:54:56 -07:00
committed by GitHub
parent 087f3d6e02
commit 0c1d39df28
9 changed files with 235 additions and 43 deletions

View File

@ -215,7 +215,7 @@ type helloServer struct {
}
func (s *helloServer) SayHello(ctx context.Context, in *hwpb.HelloRequest) (*hwpb.HelloReply, error) {
md, ok := metadata.FromContext(ctx)
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, grpc.Errorf(codes.Internal, "failed to receive metadata")
}