From 1dd1762163a2362bbc2ad89ea22213a79aa2318f Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 29 Dec 2020 11:24:07 +0300 Subject: [PATCH] [#285] object/put: Fix the loss of X-headers when forwarding objects Signed-off-by: Leonard Lyubich --- pkg/services/object/put/remote.go | 14 ++++++-------- pkg/services/object/put/streamer.go | 3 +-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/services/object/put/remote.go b/pkg/services/object/put/remote.go index eadbb2996..f1c72526e 100644 --- a/pkg/services/object/put/remote.go +++ b/pkg/services/object/put/remote.go @@ -4,7 +4,6 @@ import ( "context" "github.com/nspcc-dev/neofs-api-go/pkg/client" - "github.com/nspcc-dev/neofs-api-go/pkg/token" "github.com/nspcc-dev/neofs-node/pkg/core/object" "github.com/nspcc-dev/neofs-node/pkg/network" "github.com/nspcc-dev/neofs-node/pkg/network/cache" @@ -20,9 +19,7 @@ type remoteTarget struct { keyStorage *util.KeyStorage - token *token.SessionToken - - bearer *token.BearerToken + commonPrm *util.CommonPrm addr *network.Address @@ -57,7 +54,7 @@ func (t *remoteTarget) WriteHeader(obj *object.RawObject) error { } func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) { - key, err := t.keyStorage.GetKey(t.token) + key, err := t.keyStorage.GetKey(t.commonPrm.SessionToken()) if err != nil { return nil, errors.Wrapf(err, "(%T) could not receive private key", t) } @@ -76,9 +73,10 @@ func (t *remoteTarget) Close() (*transformer.AccessIdentifiers, error) { WithObject( t.obj.SDK(), ), - client.WithTTL(1), // FIXME: use constant - client.WithBearer(t.bearer), - client.WithSession(t.token), + append( + t.commonPrm.RemoteCallOptions(), + client.WithTTL(1), // FIXME: use constant + )..., ) if err != nil { return nil, errors.Wrapf(err, "(%T) could not put object to %s", t, addr) diff --git a/pkg/services/object/put/streamer.go b/pkg/services/object/put/streamer.go index f91421069..a9287eea1 100644 --- a/pkg/services/object/put/streamer.go +++ b/pkg/services/object/put/streamer.go @@ -140,8 +140,7 @@ func (p *Streamer) newCommonTarget(prm *PutInitPrm) transformer.ObjectTarget { return &remoteTarget{ ctx: p.ctx, keyStorage: p.keyStorage, - token: prm.common.SessionToken(), - bearer: prm.common.BearerToken(), + commonPrm: prm.common, addr: addr, clientCache: p.clientCache, clientOpts: p.clientOpts,