From ab0d06eb160c8a535b6380b56926a73c3a3a61ed Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 19 Feb 2018 15:49:39 +0000 Subject: [PATCH] fs: Make RangeOption mandatory #1825 --- fs/options.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/options.go b/fs/options.go index 9eae1d24d..dde652485 100644 --- a/fs/options.go +++ b/fs/options.go @@ -32,6 +32,19 @@ type OpenOption interface { // Note that the End is inclusive, so to fetch 100 bytes you would use // RangeOption{Start: 0, End: 99} // +// If Start is specified but End is not then it will fetch from Start +// to the end of the file. +// +// If End is specified, but Start is not then it will fetch the last +// End bytes. +// +// Examples: +// +// RangeOption{Start: 0, End: 99} - fetch the first 100 bytes +// RangeOption{Start: 100, End: 199} - fetch the second 100 bytes +// RangeOption{Start: 100} - fetch bytes from offset 100 to the end +// RangeOption{End: 100} - fetch the last 100 bytes +// // A RangeOption implements a single byte-range-spec from // https://tools.ietf.org/html/rfc7233#section-2.1 type RangeOption struct { @@ -93,7 +106,7 @@ func (o *RangeOption) String() string { // Mandatory returns whether the option must be parsed or can be ignored func (o *RangeOption) Mandatory() bool { - return false + return true } // Decode interprets the RangeOption into an offset and a limit