httprange

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxRetries = 30

DefaultMaxRetries is the default number of maximum retries before the HttpRange will give up with ErrTooManyRetries.

Variables

View Source
var ErrTooManyRetries = errors.New("Too many retries")

Error returned when the number of retries has been reached.

Functions

This section is empty.

Types

type ErrBadResponseCode

type ErrBadResponseCode int

ErrBadResponseCode is an error returned if the response code is non 200 to 299.

func (ErrBadResponseCode) Error

func (e ErrBadResponseCode) Error() string

type HTTPRange

type HTTPRange struct {
	// contains filtered or unexported fields
}

HTTPRange manages the configuration for fetching a range.

func Get

func Get(url string) *HTTPRange

Get will return a new HttpRange which will call the given URL with the GET request.

func (*HTTPRange) WithWriteObserver

func (httpRange *HTTPRange) WithWriteObserver(observer func(writtenSoFar int64, totalExpectedSize int64)) *HTTPRange

Sets the write observer for this HTTP Range. This returns the original range.

func (*HTTPRange) WriteTo

func (httpRange *HTTPRange) WriteTo(ctx context.Context, w io.Writer) (int64, error)

WriteTo will execute the request and write the response to the writer. This will check that the entire response was returned, as determined by the Content-Length of the first request, and will retry the request from the stopping point until the response has been returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL