download

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package download provide download utility functions

Index

Constants

View Source
const UserAgent = "" /* 130-byte string literal not displayed */

UserAgent HTTP请求时使用的UA

Variables

View Source
var ErrOverSize = errors.New("oversize")

ErrOverSize 响应主体过大时返回此错误

Functions

func SetTimeout added in v1.0.1

func SetTimeout(t time.Duration)

SetTimeout set internal/download client timeout

Types

type Request

type Request struct {
	Method string
	URL    string
	Header map[string]string
	Limit  int64
	Body   io.Reader
	// contains filtered or unexported fields
}

Request is a file download request

func (Request) Bytes

func (r Request) Bytes() ([]byte, error)

Bytes 对给定URL发送请求,返回响应主体

func (Request) JSON

func (r Request) JSON() (gjson.Result, error)

JSON 发送请求, 并转换响应为JSON

func (Request) WithTimeout added in v1.2.0

func (r Request) WithTimeout(t time.Duration) *Request

WithTimeout get a download instance with timeout t

func (Request) WriteToFile

func (r Request) WriteToFile(path string) error

WriteToFile 下载到制定目录

func (Request) WriteToFileMultiThreading

func (r Request) WriteToFileMultiThreading(path string, thread int) error

WriteToFileMultiThreading 多线程下载到制定目录

Jump to

Keyboard shortcuts

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