download

package
v0.0.0-...-94da729 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: AGPL-3.0 Imports: 14 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

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
}

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) 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