Documentation ¶
Index ¶
- type HttpClient
- type Logger
- type SeekingHTTP
- func (s *SeekingHTTP) Read(buf []byte) (int, error)
- func (s *SeekingHTTP) ReadAt(buf []byte, off int64) (n int, err error)
- func (s *SeekingHTTP) ReadAtWithLength(buf []byte, off, length int64) (n int, err error)
- func (s *SeekingHTTP) Seek(offset int64, whence int) (int64, error)
- func (s *SeekingHTTP) SetLogger(logger Logger)
- func (s *SeekingHTTP) Size() (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SeekingHTTP ¶
type SeekingHTTP struct { URL string MinFetch int64 KnownSize *int64 Logger Logger Client HttpClient // contains filtered or unexported fields }
SeekingHTTP uses a series of HTTP GETs with Range headers to implement io.ReadSeeker and io.ReaderAt.
NOTE: SeekingHTTP is NOT concurrency safe!
func NewWithClient ¶
func NewWithClient(url string, client HttpClient) *SeekingHTTP
NewWithClient initializes a SeekingHTTP for the given URL with a client..
func (*SeekingHTTP) ReadAt ¶
func (s *SeekingHTTP) ReadAt(buf []byte, off int64) (n int, err error)
ReadAt reads len(buf) bytes into buf starting at offset off. Returns the length read into buf.
func (*SeekingHTTP) ReadAtWithLength ¶
func (s *SeekingHTTP) ReadAtWithLength(buf []byte, off, length int64) (n int, err error)
ReadAtWithLength reads length bytes into buf starting at offset off. If the buffer is short, reads the full length & copies the beginning to the buffer. The minimum read size is controlled by MinFetch. Returns min(full length read, length) (may be larger than len(buf))
func (*SeekingHTTP) Seek ¶
func (s *SeekingHTTP) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read.
func (*SeekingHTTP) SetLogger ¶
func (s *SeekingHTTP) SetLogger(logger Logger)
func (*SeekingHTTP) Size ¶
func (s *SeekingHTTP) Size() (int64, error)
Size uses an HTTP HEAD to find out how many bytes are available in total.