Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultAgent(r *Request) error
- func Func2AddE[T, T2 any](f func(T, T2)) func(T, T2) error
- func Func2DelE[T, T2 any](f func(T, T2) error) func(T, T2)
- func FuncAddE[T any](f func(T)) func(T) error
- func FuncDelE[T any](f func(T) error) func(T)
- func ProgressReader(r io.Reader, total float64, report ProgressReport) io.Reader
- func ProgressStream(process func([]byte) (int, error), total float64, report ProgressReport) func([]byte) (int, error)
- func ProgressWriter(w io.Writer, total float64, report ProgressReport) io.Writer
- type Body
- type ClientOption
- type HeaderOption
- type Logger
- type Option
- func Accept(accept string) Option
- func Authorization(authorization string) Option
- func BasicAuth(user, pass string) Option
- func Bearer(bearerToken string) Option
- func Client(client ClientOption) Option
- func CookieAdd(cookies ...*http.Cookie) Option
- func CookieAddString(cookies ...string) Option
- func CookieEnabled(enabled ...bool) Option
- func CookieSet(cookieText string) Option
- func ErrTry(tryAt ...time.Duration) Option
- func HeaderSet(key, value string) Option
- func HeaderSets(lines ...string) Option
- func Headers(options ...HeaderOption) Option
- func Idempotent(base time.Duration, maxTimes int) Option
- func Jar(jar http.CookieJar) Option
- func Log(log Logger) Option
- func Options(options ...Option) Option
- func Proxy(proxyUrlString string) Option
- func Referer(referer string) Option
- func UserAgent(userAgent string) Option
- type PowerDownload
- type Process
- func CookieRead(read func(cookies []*http.Cookie) error) Process
- func Dump(w io.Writer, reqBody, respBody bool) Process
- func HeaderRead(read func(headers http.Header) error) Process
- func Progress(report ProgressReport) Process
- func ReadBytes(read func(data []byte) error) Process
- func ReadHeader(read func(headers http.Header) error) Process
- func StatusRead(processStatus func(status int) error) Process
- type ProgressReport
- type ProgressState
- type Request
- func (c *Request) Body(body Body) *Request
- func (c *Request) Bytes(ctx context.Context) (data []byte, err error)
- func (c *Request) Client(clientOptions ...ClientOption) *Request
- func (c *Request) Download(ctx context.Context, fn string, overwrite ...bool) (err error)
- func (c *Request) ErrTry(times ...time.Duration) *Request
- func (c *Request) Form(formBody io.Reader) *Request
- func (c *Request) FormValues(formBody url.Values) *Request
- func (c *Request) HeaderSet(key, value string) *Request
- func (c *Request) HeaderSets(lines ...string) *Request
- func (c *Request) Log(log Logger) *Request
- func (c *Request) Method(method string) *Request
- func (c *Request) Process(ctx context.Context, process Process, options ...Option) error
- func (c *Request) Referer(referer string) *Request
- func (c *Request) RoundTrip(transport http.RoundTripper) *Request
- func (c *Request) Url(url string) *Request
- func (c *Request) Use(processes ...Process) *Request
- func (c *Request) UserAgent(userAgent string) *Request
- func (c *Request) With(options ...Option) *Request
Constants ¶
View Source
const ( HeaderContentType = "Content-Type" ContentTypeForm = "application/x-www-form-urlencoded" CharsetUTF8 = "charset=utf-8" )
View Source
const ( MethodGet = http.MethodGet MethodHead = http.MethodHead MethodPost = http.MethodPost MethodPut = http.MethodPut MethodPatch = http.MethodPatch MethodDelete = http.MethodDelete MethodConnect = http.MethodConnect MethodOptions = http.MethodOptions MethodTrace = http.MethodTrace )
View Source
const DownloadTempExt = ".downloading"
View Source
const (
HeaderRequestCookie = "Cookie" // Request Cookie
)
View Source
const Version = "0.0.1"
Variables ¶
View Source
var ( WindowsEdgeAgent = UserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43") MacSafariAgent = UserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15") IOSSafariAgent = UserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4") AndroidWebkitAgent = UserAgent("Mozilla/5.0 (Linux; Android 11; SM-G9910) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30") )
Functions ¶
func DefaultAgent ¶
func ProgressReader ¶
func ProgressStream ¶
func ProgressWriter ¶
Types ¶
type ClientOption ¶
type HeaderOption ¶
type PowerDownload ¶
type PowerDownload struct {
// contains filtered or unexported fields
}
func Power ¶
func Power(url, dir, name string) *PowerDownload
type ProgressReport ¶
type ProgressReport func(state ProgressState)
type ProgressState ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request 请求构造
func (*Request) Client ¶
func (c *Request) Client(clientOptions ...ClientOption) *Request
Client 使用自定义的HTTP客户端
func (*Request) HeaderSets ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.