request

package
v0.0.0-...-55e8476 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UserAgent UserAgent
	UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
)

Functions

func Download

func Download(dl *DownloadTask, timeout time.Duration) (err error)

func DownloadWithContext

func DownloadWithContext(ctx context.Context, dl *DownloadTask) (err error)

func Get

func Get(url string) (io.ReadCloser, error)

Get http get request

func HTTPGet

func HTTPGet(url string) (body []byte, err error)

HTTPGet http get request

func Headers

func Headers(url string) (http.Header, error)

Headers return the HTTP Headers of the url

func NewClient

func NewClient(baseURL string) *resty.Client

NewClient new HTTPClient

func Size

func Size(url string) (int, error)

Size get size of the url

Types

type DownloadTask

type DownloadTask struct {
	Link string
	Path string
	Err  error
}

func NewDownloadTask

func NewDownloadTask(link, path string) *DownloadTask

type DownloadTasks

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

func Batch

func Batch(tasks *DownloadTasks, concurrent int, eachTimeout time.Duration) *DownloadTasks

func NewDownloadTasks

func NewDownloadTasks() *DownloadTasks

func (*DownloadTasks) Add

func (d *DownloadTasks) Add(link, path string)

func (*DownloadTasks) ForEach

func (d *DownloadTasks) ForEach(f func(t *DownloadTask))

type GetDownload

type GetDownload struct {
	OnEachStart func(t *DownloadTask)
	OnEachStop  func(t *DownloadTask)
	OnEachSkip  func(t *DownloadTask)
	Header      http.Header
	Client      http.Client
}

func Default

func Default() (g GetDownload)

func (*GetDownload) Batch

func (g *GetDownload) Batch(tasks *DownloadTasks, concurrent int, eachTimeout time.Duration) *DownloadTasks

func (*GetDownload) Download

func (g *GetDownload) Download(task *DownloadTask, timeout time.Duration) (err error)

func (*GetDownload) DownloadWithContext

func (g *GetDownload) DownloadWithContext(ctx context.Context, task *DownloadTask) (err error)

type HTTPClient

type HTTPClient struct {
	resty.Client
}

HTTPClient http client

Jump to

Keyboard shortcuts

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