[#285] object/put: Fix the loss of X-headers when forwarding objects

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-12-29 11:24:07 +03:00 committed by Alex Vanin
parent 2897e83fb2
commit 1dd1762163
2 changed files with 7 additions and 10 deletions

View file

@ -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(),
),
append(
t.commonPrm.RemoteCallOptions(),
client.WithTTL(1), // FIXME: use constant
client.WithBearer(t.bearer),
client.WithSession(t.token),
)...,
)
if err != nil {
return nil, errors.Wrapf(err, "(%T) could not put object to %s", t, addr)

View file

@ -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,