Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoOverlap is returned by ParseRange if first-byte-pos of // all of the byte-range-spec values is greater than the content size. ErrNoOverlap = errors.New("invalid range: failed to overlap") // ErrInvalid is returned by ParseRange on invalid input. ErrInvalid = errors.New("invalid range") )
Functions ¶
func NewSeqRangingClient ¶ added in v0.6.0
func NewSeqRangingClient(ranger Ranger, client *http.Client) http.RoundTripper
func NewSeqReader ¶ added in v0.6.0
func NewSeqReader(client *http.Client, url string, ranger SizedRanger) io.ReadSeekCloser
NewSeqReader returns a new io.ReadSeekCloser that reads from the given url using the given client. Instead of reading the whole file at once, it reads the file in sequential chunks, using the given ranger to determine the ranges to read. This allows for reading very large files in CDN-cacheable chunks using RANGE GETs.
Types ¶
type ByteRange ¶
ByteRange represents a range of bytes available in a file
func (ByteRange) RangeHeader ¶ added in v0.2.0
RangeHeader returns the HTTP header representation of the byte range, suitable for use in the Range header, as described in https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Range
type Range ¶ added in v0.7.1
Range specifies the byte range to be sent to the client.
func ParseRange ¶ added in v0.7.1
ParseRange parses a Range header string as per RFC 7233. ErrNoOverlap is returned if none of the ranges overlap. ErrInvalid is returned if s is invalid range.
func (Range) ContentRange ¶ added in v0.7.1
ContentRange returns Content-Range header value.
type Ranger ¶
type Ranger struct {
// contains filtered or unexported fields
}
Ranger can split a file into chunks of a given size.
func NewRanger ¶
NewRanger creates a new Ranger with the given chunk size. If the chunk size is <= 0, the default chunk size is used.
type SizedRanger ¶ added in v0.6.0
type SizedRanger struct {
// contains filtered or unexported fields
}
func NewSizedRanger ¶ added in v0.6.0
func NewSizedRanger(length int64, ranger Ranger) SizedRanger
func (SizedRanger) Length ¶ added in v0.6.0
func (r SizedRanger) Length() int64
func (SizedRanger) RangeContaining ¶ added in v0.7.0
func (r SizedRanger) RangeContaining(offset int64) (br ByteRange)