Documentation
¶
Index ¶
- type HTTPRangeReader
- func (r *HTTPRangeReader) Read(buf []byte) (int, error)
- func (r *HTTPRangeReader) ReadAt(buf []byte, off int64) (int, error)
- func (r *HTTPRangeReader) Seek(offset int64, whence int) (int64, error)
- func (r *HTTPRangeReader) SetSize(size uint64)
- func (r *HTTPRangeReader) Size() (uint64, error)
- func (r *HTTPRangeReader) SliceReadAt(offset, length int64) (dataOffset int64, data []byte, err error)
- type HttpClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPRangeReader ¶
type HTTPRangeReader struct {
// contains filtered or unexported fields
}
HTTPRangeReader uses HTTP requests with Range headers to implement io.ReadSeeker and io.ReaderAt. It is concurrency safe.
While Read() and Seek() are concurrency safe, the behavior while using them concurrently is undefined. Only use ReadAt concurrently.
Note that the body of the passed request is ignored. The method of the request is changed to HEAD for Size(). Call SetSize to avoid a HEAD request.
if le is nil all logging will be disabled verbose logs all http responses even if successful
func NewHTTPRangeReader ¶
func NewHTTPRangeReader(le *logrus.Entry, request *http.Request, client HttpClient, verbose bool) *HTTPRangeReader
NewHTTPRangeReader initializes a HTTPRangeReader for the given request.
func (*HTTPRangeReader) Read ¶
func (r *HTTPRangeReader) Read(buf []byte) (int, error)
Read implements the io.Reader interface for HTTPRangeReader.
func (*HTTPRangeReader) ReadAt ¶
func (r *HTTPRangeReader) ReadAt(buf []byte, off int64) (int, error)
ReadAt reads len(buf) bytes into buf starting at offset off.
func (*HTTPRangeReader) Seek ¶
func (r *HTTPRangeReader) Seek(offset int64, whence int) (int64, error)
Seek sets the offset for the next Read or ReadAt operation.
func (*HTTPRangeReader) SetSize ¶
func (r *HTTPRangeReader) SetSize(size uint64)
SetSize sets the size of the remote file, avoiding a HEAD request.
func (*HTTPRangeReader) Size ¶
func (r *HTTPRangeReader) Size() (uint64, error)
Size uses an HTTP HEAD request to find out the total available bytes. If the HEAD request does not return a Content-Length, it attempts a GET request. If the GET request also lacks a Content-Length, it reads the entire body to determine the size.
func (*HTTPRangeReader) SliceReadAt ¶
func (r *HTTPRangeReader) SliceReadAt(offset, length int64) (dataOffset int64, data []byte, err error)
SliceReadAt reads a slice of data from the requested location. NOTE: the returned slice may start before or after the requested location and length. NOTE: this may return a completely different range than what you asked for!