httpdl

package module
v0.0.0-...-2ddff92 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnDownloadStartEvent    = 0
	OnDownloadCompleteEvent = 1
	OnDownloadStopEvent     = 2
)

Variables

This section is empty.

Functions

func RandString

func RandString(n int) string

func ResponseCodeNotSuccessFullError

func ResponseCodeNotSuccessFullError(statusCode int) error

Types

type AddDownloadOpts

type AddDownloadOpts struct {
	Connections int
	Dir         string
	Chunksize   int64
	Filename    string
	Size        int64
	Fallocate   bool
}

type DownloadEvent

type DownloadEvent int

type DownloadPart

type DownloadPart struct {
	Id int

	Err error
	// contains filtered or unexported fields
}

func (*DownloadPart) CompletedLength

func (d *DownloadPart) CompletedLength() int64

func (*DownloadPart) Download

func (d *DownloadPart) Download() error

func (*DownloadPart) HandleResponse

func (d *DownloadPart) HandleResponse(resp *http.Response) error

func (*DownloadPart) HandleResponseWriter

func (d *DownloadPart) HandleResponseWriter(resp *http.Response) error

func (*DownloadPart) TotalLength

func (d *DownloadPart) TotalLength() int64

func (*DownloadPart) Write

func (d *DownloadPart) Write(p []byte) (int, error)

type HTTPDownload

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

func (*HTTPDownload) CancelDownload

func (h *HTTPDownload) CancelDownload()

func (*HTTPDownload) CompletedLength

func (h *HTTPDownload) CompletedLength() int64

func (*HTTPDownload) GetFailureError

func (h *HTTPDownload) GetFailureError() error

func (*HTTPDownload) GetFileHandle

func (h *HTTPDownload) GetFileHandle() *os.File

func (*HTTPDownload) Gid

func (h *HTTPDownload) Gid() string

func (*HTTPDownload) Init

func (h *HTTPDownload) Init()

func (*HTTPDownload) IsCancelled

func (h *HTTPDownload) IsCancelled() bool

func (*HTTPDownload) IsCompleted

func (h *HTTPDownload) IsCompleted() bool

func (*HTTPDownload) IsFailed

func (h *HTTPDownload) IsFailed() bool

func (*HTTPDownload) Name

func (h *HTTPDownload) Name() string

func (*HTTPDownload) Speed

func (h *HTTPDownload) Speed() int64

func (*HTTPDownload) SpeedObserver

func (h *HTTPDownload) SpeedObserver()

func (*HTTPDownload) StartDownload

func (h *HTTPDownload) StartDownload()

func (*HTTPDownload) TotalLength

func (h *HTTPDownload) TotalLength() int64

type HTTPDownloadListener

type HTTPDownloadListener interface {
	OnDownloadStart(*HTTPDownload)
	OnDownloadComplete(*HTTPDownload)
	OnDownloadStop(*HTTPDownload)
}

type HTTPDownloader

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

func NewHTTPDownloader

func NewHTTPDownloader(client *http.Client) *HTTPDownloader

func (*HTTPDownloader) AddDownload

func (h *HTTPDownloader) AddDownload(url string, opts *AddDownloadOpts) (*HTTPDownload, error)

func (*HTTPDownloader) AddListener

func (h *HTTPDownloader) AddListener(listener HTTPDownloadListener)

func (*HTTPDownloader) GetURLProperties

func (h *HTTPDownloader) GetURLProperties(url string) (*URLProperties, error)

func (*HTTPDownloader) HeaderSupportsByteRange

func (h *HTTPDownloader) HeaderSupportsByteRange(header http.Header) bool

func (*HTTPDownloader) ListenForEvents

func (h *HTTPDownloader) ListenForEvents(download *HTTPDownload)

func (*HTTPDownloader) NotifyListeners

func (h *HTTPDownloader) NotifyListeners(event DownloadEvent, download *HTTPDownload)

func (*HTTPDownloader) SniffFilename

func (h *HTTPDownloader) SniffFilename(url string, header http.Header) string

type URLProperties

type URLProperties struct {
	SupportsMultiConnection bool
	Size                    int64
	SupportsRange           bool
	Filename                string
}

Jump to

Keyboard shortcuts

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