// GetGRPCHeader retrieves the last value found for a particular key. If key is
// not found it returns an empty string.
169210
func GetGRPCHeader(md *metadata.MD, key string) string {
	v := (*md)[key]
	if len(v) < 1 {
		return ""
	}
	return v[len(v)-1]
}
1017273
func ToGRPC(err error) error {
	if err == nil {
		return nil
	}
	return status.Errorf(codes.Code(Code(err)), "%v", truncateError(err))
}
377190
func Header(md *metadata.MD) *CallOption {
	return &CallOption{
		grpc.Header(md),
		func(o *Options) {
			o.resHeaderMetadata = md
		},
	}
}
868921
func (F *Frisby) ExpectHeader(key, value string) *Frisby {
	Global.NumAsserts++
	chk_val := F.Resp.Header.Get(key)
	if chk_val == "" {
		err_str := fmt.Sprintf("Expected Header %q, but it was missing", key)
		F.AddError(err_str)
	} else if chk_val != value {
		err_str := fmt.Sprintf("Expected Header %q to be %q, but got %q", key, value, chk_val)
		F.AddError(err_str)
	}
	return F
}
849342
func (e *ExchangeMessage) GetHeader(k string) string {
	return e.head.Get(k)
}
1095207
func (s *ChainService) GetBlockHeader(
	blockHash *chainhash.Hash) (*wire.BlockHeader, error) {
	header, _, err := s.BlockHeaders.FetchHeader(blockHash)
	return header, err
}
604857
func (req *Request) GetHttpHeader(key string) string {
	return req.Header.Get(key)
}
485087
func (clnt *Client) GetHeader(policy *BasePolicy, key *Key) (*Record, error) {
	policy = clnt.getUsablePolicy(policy)

	command := newReadHeaderCommand(clnt.cluster, policy, key)
	if err := command.Execute(); err != nil {
		return nil, err
	}
	return command.GetRecord(), nil
}
640736
func decodeGRPCConcatRequest(_ context.Context, grpcReq interface{}) (interface{}, error) {
	req := grpcReq.(*pb.ConcatRequest)
	return addendpoint.ConcatRequest{A: req.A, B: req.B}, nil
}
508545
func GetNetHttpHeaders(httpHeaders []*cilium.KeyValue) http.Header {
	headers := make(http.Header)

	for _, header := range httpHeaders {
		headers.Add(header.Key, header.Value)
	}

	return headers
}
737191
func getHeader(item *Item, done chan bool, wg *sync.WaitGroup) {
	defer wg.Done()
	item.GetHeader()
	done <- true
}
538646
func EncodeGRPCDeleteSessionsByOwnerTokenResponse(_ context.Context, response interface{}) (interface{}, error) {
	res := response.(deleteSessionsByOwnerTokenResponse)
	return &pb.DeleteSessionsByOwnerTokenReply{
		Sessions: toPBSessions(res.Sessions),
		Err:      toPBError(res.Err),
	}, nil
}
1259493
func (bc *BlockChain) GetHeaderByHash(hash common.Hash) *types.Header {
	return bc.hc.GetHeaderByHash(hash)
}
826482
func (ctx *Context) GetHeader(key string) string {
	switch key {
	case "Referer", "referer", "Referrer", "referrer":
		if val := ctx.Req.Header.Get("Referer"); val != "" {
			return val
		}
		return ctx.Req.Header.Get("Referrer")
	default:
		return ctx.Req.Header.Get(key)
	}
}
1021378
func (s Server) ServeGRPC(ctx context.Context, req interface{}) (retctx context.Context, resp interface{}, err error) {
	// Retrieve gRPC metadata.
	md, ok := metadata.FromIncomingContext(ctx)
	if !ok {
		md = metadata.MD{}
	}

	if len(s.finalizer) > 0 {
		defer func() {
			for _, f := range s.finalizer {
				f(ctx, err)
			}
		}()
	}

	for _, f := range s.before {
		ctx = f(ctx, md)
	}

	var (
		request  interface{}
		response interface{}
		grpcResp interface{}
	)

	request, err = s.dec(ctx, req)
	if err != nil {
		s.errorHandler.Handle(ctx, err)
		return ctx, nil, err
	}

	response, err = s.e(ctx, request)
	if err != nil {
		s.errorHandler.Handle(ctx, err)
		return ctx, nil, err
	}

	var mdHeader, mdTrailer metadata.MD
	for _, f := range s.after {
		ctx = f(ctx, &mdHeader, &mdTrailer)
	}

	grpcResp, err = s.enc(ctx, response)
	if err != nil {
		s.errorHandler.Handle(ctx, err)
		return ctx, nil, err
	}

	if len(mdHeader) > 0 {
		if err = grpc.SendHeader(ctx, mdHeader); err != nil {
			s.errorHandler.Handle(ctx, err)
			return ctx, nil, err
		}
	}

	if len(mdTrailer) > 0 {
		if err = grpc.SetTrailer(ctx, mdTrailer); err != nil {
			s.errorHandler.Handle(ctx, err)
			return ctx, nil, err
		}
	}

	return ctx, grpcResp, nil
}
1329291
func (bc *BlockChain) GetHeader(hash common.Hash, number uint64) *types.Header {
	return bc.hc.GetHeader(hash, number)
}
437675
func ContextToGRPC() grpc.ClientRequestFunc {
	return func(ctx context.Context, md *metadata.MD) context.Context {
		token, ok := ctx.Value(JWTTokenContextKey).(string)
		if ok {
			// capital "Key" is illegal in HTTP/2.
			(*md)["authorization"] = []string{generateAuthHeaderFromToken(token)}
		}

		return ctx
	}
}