httpclient

package
v0.0.0-...-f7d1039 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorHttpsClientInsecureSkipVerify = errors.New("Configuration file HttpsClient_InsecureSkipVerify  filled in error")
)

Functions

This section is empty.

Types

type OwlClient

type OwlClient struct {
	*OwlHttp
}

定义HTTP客户端结构

func NewOwlClient

func NewOwlClient() *OwlClient

创建HttpClient实体

func (*OwlClient) GetValue

func (c *OwlClient) GetValue(address, key string) *Response

获取Key值

type OwlHttp

type OwlHttp struct {
	Request          *http.Request
	Client           *http.Client
	HCRequestTimeout time.Duration
	Query            url.Values //QueryString。url.Values结构是map[string][]string非并发安全
	Param            url.Values //PostFromParams。url.Values结构是map[string][]string非并发安全
}

func NewOwlHttpClient

func NewOwlHttpClient() *OwlHttp

创建HttpClient实体

func (*OwlHttp) AddCookie

func (h *OwlHttp) AddCookie(key, value string)

设置Request的Cookie

func (*OwlHttp) BasicAuth

func (h *OwlHttp) BasicAuth(username, password string)

设置BasicAuth

func (*OwlHttp) Body

func (h *OwlHttp) Body(body io.Reader)

设置Request的Body

func (*OwlHttp) Claer

func (h *OwlHttp) Claer() *OwlHttp

清空数据

func (*OwlHttp) Do

func (h *OwlHttp) Do() (*Response, error)

Do return Response and err

func (*OwlHttp) EchoInfo

func (h *OwlHttp) EchoInfo()

打印数据,测试用

func (*OwlHttp) Get

func (h *OwlHttp) Get(Url string)

设置GET请求

func (*OwlHttp) Header

func (h *OwlHttp) Header() http.Header

返回Header

func (*OwlHttp) Host

func (h *OwlHttp) Host(hostname string)

设置Request的header的Host

func (*OwlHttp) Post

func (h *OwlHttp) Post(Url, bodyType string, body io.Reader)

设置POST请求

func (*OwlHttp) PostForm

func (h *OwlHttp) PostForm(Url string)

设置POST请求(表单形式)

func (*OwlHttp) SetTimeout

func (h *OwlHttp) SetTimeout(t time.Duration)

设置Request的timeout

func (*OwlHttp) UserAgent

func (h *OwlHttp) UserAgent(useragent string)

设置Request的User-Agent

type Response

type Response struct {
	*http.Response
}

func (*Response) Byte

func (r *Response) Byte() []byte

获取的数据结果转[]byte

func (*Response) DownLoadFile

func (r *Response) DownLoadFile(filepath string) error

Response body save as a file

func (*Response) JsonUnmarshal

func (r *Response) JsonUnmarshal(v interface{}) error

Json.Unmarshal ResponseBody

func (*Response) String

func (r *Response) String() string

获取的数据结果转string

Jump to

Keyboard shortcuts

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