diff --git a/client/object_get.go b/client/object_get.go index b0a50b36..9412c660 100644 --- a/client/object_get.go +++ b/client/object_get.go @@ -671,6 +671,9 @@ func (x *ObjectRangeReader) Read(p []byte) (int, error) { // ObjectRangeInit initiates reading an object's payload range through a remote // server using NeoFS API protocol. // +// To get full payload, set both offset and length to zero. Otherwise, length +// must not be zero. +// // The call only opens the transmission channel, explicit fetching is done using the ObjectRangeReader. // Exactly one return value is non-nil. Resulting reader must be finally closed. // @@ -692,7 +695,7 @@ func (c *Client) ObjectRangeInit(ctx context.Context, containerID cid.ID, object }() } - if length == 0 { + if length == 0 && offset != 0 { err = ErrZeroRangeLength return nil, err } diff --git a/client/object_get_test.go b/client/object_get_test.go index 2001408d..e6741b80 100644 --- a/client/object_get_test.go +++ b/client/object_get_test.go @@ -284,7 +284,7 @@ func (x *testGetObjectPayloadRangeServer) verifyRequest(req *protoobject.GetRang if body.Range == nil { return newErrMissingRequestBodyField("range") } - if body.Range.Length == 0 { + if body.Range.Length == 0 && body.Range.Offset != 0 { return newErrInvalidRequestField("range", errors.New("zero length")) } if x.reqRng != nil { diff --git a/client/object_hash.go b/client/object_hash.go index 5bcd6cbe..7ddc21f7 100644 --- a/client/object_hash.go +++ b/client/object_hash.go @@ -75,6 +75,9 @@ func (x *PrmObjectHash) UseSalt(salt []byte) { // ObjectHash requests checksum of the range list of the object payload using // NeoFS API protocol. // +// To hash full payload, set both offset and length to zero. Otherwise, length +// must not be zero. +// // Returns a list of checksums in raw form: the format of hashes and their number // is left for the caller to check. Client preserves the order of the server's response. //