diff --git a/pkg/services/object/range/prm.go b/pkg/services/object/range/prm.go index 8d9f01ed..730f8a5d 100644 --- a/pkg/services/object/range/prm.go +++ b/pkg/services/object/range/prm.go @@ -5,7 +5,7 @@ import ( ) type Prm struct { - local bool + local, full bool addr *object.Address @@ -37,3 +37,11 @@ func (p *Prm) WithRange(v *object.Range) *Prm { return p } + +func (p *Prm) FullRange() *Prm { + if p != nil { + p.full = true + } + + return p +} diff --git a/pkg/services/object/range/service.go b/pkg/services/object/range/service.go index 5ecbfec7..6f36d0e2 100644 --- a/pkg/services/object/range/service.go +++ b/pkg/services/object/range/service.go @@ -64,12 +64,16 @@ func (s *Service) GetRange(ctx context.Context, prm *Prm) (*Result, error) { return nil, errors.Wrapf(err, "(%T) could not receive Head result", s) } - off, ln := prm.rng.GetOffset(), prm.rng.GetLength() - origin := headResult.Header() originSize := origin.GetPayloadSize() - if originSize < off+ln { + + if prm.full { + prm.rng = new(object.Range) + prm.rng.SetLength(originSize) + } + + if originSize < prm.rng.GetOffset()+prm.rng.GetLength() { return nil, errors.Errorf("(%T) requested payload range is out-of-bounds", s) }