http

package
v0.2.52 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 12 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type C added in v0.2.21

type C struct {
	Transport *http.Transport
	Header    map[string]string //全局头部
	// contains filtered or unexported fields
}

C 客户端结构体

func Client

func Client() *C

Client 获取客户端

func (*C) Request added in v0.2.21

func (c *C) Request() *R

func (*C) SetHeader added in v0.2.25

func (c *C) SetHeader(header map[string]string) *C

SetHeader 设置全局header

func (*C) SetProxyAddress added in v0.2.23

func (c *C) SetProxyAddress(address string) *C

SetProxyAddress 设置代理地址

func (*C) SetTimeout added in v0.2.21

func (c *C) SetTimeout(time time.Duration) *C

SetTimeout 设置超时时间

type R added in v0.2.21

type R struct {
	Request   *http.Request
	Parameter map[string]interface{} //参数

	Header     map[string]string //header
	ReTryTimes int               //重试次数
	// contains filtered or unexported fields
}

R request构造体

func (*R) DownloadFile added in v0.2.21

func (r *R) DownloadFile(url string, path string) error

DownloadFile 下载文件

func (*R) DownloadImage added in v0.2.21

func (r *R) DownloadImage(url string, path string) error

DownloadImage 图片下载

func (*R) GetToBody added in v0.2.21

func (r *R) GetToBody(url string) (io.ReadCloser, error)

GetToBody 注意要手动关闭body

func (*R) GetToResp added in v0.2.21

func (r *R) GetToResp(url string) (*http.Response, error)

GetToResp 注意要手动关闭body

func (*R) GetToString added in v0.2.21

func (r *R) GetToString(url string) (string, error)

func (*R) GetToStringWithHeader added in v0.2.21

func (r *R) GetToStringWithHeader(url string) (string, http.Header, error)

GetToStringWithHeader get获取字符串结果并返回头部信息

func (*R) PostToString added in v0.2.21

func (r *R) PostToString(url string) (string, error)

PostToString post获取字符串结果

func (*R) SetHeader added in v0.2.22

func (r *R) SetHeader(header map[string]string) *R

SetHeader 设置header

func (*R) SetParameter added in v0.2.21

func (r *R) SetParameter(p map[string]interface{}) *R

SetParameter 设置请求参数

func (*R) SetReTryTimes added in v0.2.26

func (r *R) SetReTryTimes(times int) *R

SetReTryTimes 设置重试次数

Jump to

Keyboard shortcuts

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