client

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadToFile added in v0.1.0

func DownloadToFile(filename, url string, tryTime int) error

DownloadToFile 下载文件,并返回其绝对路径

func ParseReader added in v0.1.0

func ParseReader(reader io.Reader) gjson.Result

Types

type HttpClient

type HttpClient struct {
	HttpOptions
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(option *HttpOptions) *HttpClient

NewHttpClient 创建新Http请求器

func (*HttpClient) AddCookie added in v0.1.0

func (c *HttpClient) AddCookie(cookie ...*http.Cookie)

func (HttpClient) Do

func (c HttpClient) Do(req *http.Request) (*http.Response, error)

func (*HttpClient) DownloadToFile added in v0.1.0

func (c *HttpClient) DownloadToFile(filename, url string) error

DownloadToFile 下载文件,并返回其绝对路径

func (HttpClient) Get

func (c HttpClient) Get(url string) (*http.Response, error)

func (HttpClient) GetGJson added in v0.1.0

func (c HttpClient) GetGJson(url string) (gjson.Result, error)

GetGJson 通过Get请求获取回包Body(gjson.Result)

func (HttpClient) GetReader

func (c HttpClient) GetReader(url string) (io.ReadCloser, error)

GetReader 通过Get请求获取回包Body(io.Reader)

func (HttpClient) Head added in v0.3.1

func (c HttpClient) Head(url string) (*http.Response, error)

Head 发送Head请求

func (HttpClient) Post

func (c HttpClient) Post(url, contentType string, body io.Reader) (*http.Response, error)

func (HttpClient) PostForm added in v0.1.0

func (c HttpClient) PostForm(url string, data url.Values) (resp *http.Response, err error)

func (HttpClient) PostFormByMap added in v0.1.0

func (c HttpClient) PostFormByMap(URL string, data map[string]string) (resp *http.Response, err error)

func (HttpClient) PostJson added in v0.1.0

func (c HttpClient) PostJson(url string, data interface{}) (gjson.Result, error)

func (HttpClient) PostMarshal added in v0.1.0

func (c HttpClient) PostMarshal(url string, data interface{}, response interface{}) error

func (*HttpClient) SetHeader added in v0.1.0

func (c *HttpClient) SetHeader(key string, val string)

func (*HttpClient) SetUserAgent added in v0.1.0

func (c *HttpClient) SetUserAgent()

type HttpOptions

type HttpOptions struct {
	TryTime int
	Timeout time.Duration
	SetJar  bool
}

Jump to

Keyboard shortcuts

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