diff --git a/pkg/services/object/head/local.go b/pkg/services/object/head/local.go index b2d910807..1435c7b44 100644 --- a/pkg/services/object/head/local.go +++ b/pkg/services/object/head/local.go @@ -13,7 +13,7 @@ type localHeader struct { } func (h *localHeader) head(ctx context.Context, prm *Prm, handler func(*object.Object)) error { - head, err := engine.Head(h.storage, prm.addr) + head, err := engine.HeadRaw(h.storage, prm.addr, prm.raw) if err != nil { return errors.Wrapf(err, "(%T) could not get header from local storage", h) } diff --git a/pkg/services/object/head/prm.go b/pkg/services/object/head/prm.go index 167bdb4bb..7a7e62d1f 100644 --- a/pkg/services/object/head/prm.go +++ b/pkg/services/object/head/prm.go @@ -11,6 +11,8 @@ type Prm struct { short bool addr *object.Address + + raw bool } func (p *Prm) WithCommonPrm(v *util.CommonPrm) *Prm { @@ -36,3 +38,11 @@ func (p *Prm) WithAddress(v *object.Address) *Prm { return p } + +func (p *Prm) WithRaw(v bool) *Prm { + if p != nil { + p.raw = v + } + + return p +} diff --git a/pkg/services/object/head/remote.go b/pkg/services/object/head/remote.go index e6979e328..eeeb1cec8 100644 --- a/pkg/services/object/head/remote.go +++ b/pkg/services/object/head/remote.go @@ -74,7 +74,8 @@ func (h *RemoteHeader) Head(ctx context.Context, prm *RemoteHeadPrm) (*object.Ob } p := new(client.ObjectHeaderParams). - WithAddress(prm.commonHeadPrm.addr) + WithAddress(prm.commonHeadPrm.addr). + WithRawFlag(prm.commonHeadPrm.raw) if prm.commonHeadPrm.short { p = p.WithMainFields() diff --git a/pkg/services/object/head/v2/service.go b/pkg/services/object/head/v2/service.go index fbb8985a1..728a46192 100644 --- a/pkg/services/object/head/v2/service.go +++ b/pkg/services/object/head/v2/service.go @@ -3,6 +3,7 @@ package headsvc import ( "context" + "github.com/nspcc-dev/neofs-api-go/pkg/object" objectV2 "github.com/nspcc-dev/neofs-api-go/v2/object" headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head" "github.com/pkg/errors" @@ -40,6 +41,12 @@ func (s *Service) Head(ctx context.Context, req *objectV2.HeadRequest) (*objectV return nil, errors.Wrapf(err, "(%T) could not get object header", s) } + var splitErr *object.SplitInfoError + + if errors.As(err, &splitErr) { + return splitInfoResponse(splitErr.SplitInfo()), nil + } + return fromResponse(r, req.GetBody().GetMainOnly()), nil } diff --git a/pkg/services/object/head/v2/util.go b/pkg/services/object/head/v2/util.go index 4066be22d..be41a9cfe 100644 --- a/pkg/services/object/head/v2/util.go +++ b/pkg/services/object/head/v2/util.go @@ -15,7 +15,8 @@ func toPrm(req *objectV2.HeadRequest) *headsvc.Prm { object.NewAddressFromV2(body.GetAddress()), ). Short(body.GetMainOnly()). - WithCommonPrm(util.CommonPrmFromV2(req)) + WithCommonPrm(util.CommonPrmFromV2(req)). + WithRaw(body.GetRaw()) } func fromResponse(r *headsvc.Response, short bool) *objectV2.HeadResponse { @@ -55,3 +56,14 @@ func shortPartFromResponse(r *headsvc.Response) objectV2.GetHeaderPart { return sh } + +func splitInfoResponse(info *object.SplitInfo) *objectV2.HeadResponse { + resp := new(objectV2.HeadResponse) + + body := new(objectV2.HeadResponseBody) + resp.SetBody(body) + + body.SetHeaderPart(info.ToV2()) + + return resp +}