From c69f867af1519c572566399a9acfdd33d2845725 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 28 Dec 2020 18:55:16 +0300 Subject: [PATCH] [#285] services/object: Add X-Headers to client call options Forward request X-headers to client calls during internal processing of Object operations on the node. Signed-off-by: Leonard Lyubich --- pkg/services/object/util/prm.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/services/object/util/prm.go b/pkg/services/object/util/prm.go index 995f5bcbe..a34f3e97b 100644 --- a/pkg/services/object/util/prm.go +++ b/pkg/services/object/util/prm.go @@ -3,6 +3,7 @@ package util import ( "crypto/ecdsa" + "github.com/nspcc-dev/neofs-api-go/pkg" "github.com/nspcc-dev/neofs-api-go/pkg/client" "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-api-go/v2/session" @@ -109,11 +110,15 @@ func CommonPrmFromV2(req interface { }) *CommonPrm { meta := req.GetMetaHeader() + xHdrs := meta.GetXHeaders() + + const staticOptNum = 3 + prm := &CommonPrm{ local: meta.GetTTL() <= 1, // FIXME: use constant token: nil, bearer: nil, - callOpts: make([]client.CallOption, 0, 3), + callOpts: make([]client.CallOption, 0, staticOptNum+len(xHdrs)), } prm.callOpts = append(prm.callOpts, client.WithTTL(meta.GetTTL()-1)) @@ -128,5 +133,13 @@ func CommonPrmFromV2(req interface { prm.callOpts = append(prm.callOpts, client.WithBearer(prm.bearer)) } + for i := range xHdrs { + prm.callOpts = append(prm.callOpts, + client.WithXHeader( + pkg.NewXHeaderFromV2(xHdrs[i]), + ), + ) + } + return prm }