gdl

package module
v0.0.0-...-7cb8faf Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: MIT Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{
	Transport: &http.Transport{
		MaxIdleConns:        10,
		IdleConnTimeout:     30 * time.Second,
		TLSHandshakeTimeout: 5 * time.Second,
		Proxy:               http.ProxyFromEnvironment,
	},
}
View Source
var DefaultFileName = "gdl.output"
View Source
var ErrDownloadAborted = errors.New("Operation aborted")
View Source
var UserAgent = "GDL/1.0"

Functions

func Fetch

func Fetch(url string, dir string, dest string, chunksize uint64) (err error)

func GetFilename

func GetFilename(URL string) string

func NewRequest

func NewRequest(ctx context.Context, method, URL string, header []GdlHeader) (req *http.Request, err error)

Types

type Chunk

type Chunk struct {
	Start, End uint64
}

type Download

type Download struct {
	Client                                          *http.Client
	Concurrency                                     uint
	URL, Dir, Dest                                  string
	Interval, ChunkSize, MinChunkSize, MaxChunkSize uint64
	Header                                          []GdlHeader
	// contains filtered or unexported fields
}

func (*Download) Context

func (d *Download) Context() context.Context

func (*Download) DownloadChunk

func (d *Download) DownloadChunk(c *Chunk, dest io.Writer) error

func (*Download) GetInfoOrDownload

func (d *Download) GetInfoOrDownload() (*Info, error)

func (*Download) Init

func (d *Download) Init() (err error)

func (*Download) Path

func (d *Download) Path() string

func (*Download) Size

func (d *Download) Size() uint64

func (*Download) Start

func (d *Download) Start() (err error)

func (*Download) TotalSize

func (d *Download) TotalSize() uint64

func (*Download) Write

func (d *Download) Write(b []byte) (int, error)

type Gdl

type Gdl struct {
	Client *http.Client
	// contains filtered or unexported fields
}

func New

func New() *Gdl

func NewWithContext

func NewWithContext(ctx context.Context) *Gdl

func (Gdl) Do

func (g Gdl) Do(dl *Download) error

func (Gdl) Download

func (g Gdl) Download(URL, dest string) error

type GdlHeader

type GdlHeader struct {
	Key   string
	Value string
}

type Info

type Info struct {
	Size      uint64
	Rangeable bool
}

type OffsetWriter

type OffsetWriter struct {
	io.WriterAt
	// contains filtered or unexported fields
}

func (*OffsetWriter) Write

func (dst *OffsetWriter) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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