httpClientKit

package
v1.13.11 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultTimeout 发送请求的默认超时时间.
	/*
		PS:
		(1) 个人实测,对于 http.Client 结构体,Timeout 默认为30s.
		(2) e.g. yozo的网访问谷歌必定超时.
	*/
	DefaultTimeout = time.Second * 6
)

Functions

func AssertHttpStatusCodeSuccessful

func AssertHttpStatusCodeSuccessful(statusCode int) error

AssertHttpStatusCodeSuccessful 断言http状态码是否成功

PS: 判断参考了jQuery.

func Get

func Get(url string, params map[string]string) (int, []byte, error)

Get 发送GET请求(可用于下载文件等场景)

@param params 请求参数,可以为nil @return http状态码 + 响应内容 + error

参考: golang 将图片生成Base64 https://blog.csdn.net/weixin_40292098/article/details/126029489

func Post

func Post(url string, params map[string]string) (int, []byte, error)

Post

@param params 请求参数,可以为nil @return http状态码 + 响应内容 + error

func SimpleGet

func SimpleGet(url string, params map[string]string) ([]byte, error)

SimpleGet 额外处理了http状态码

func SimplePost

func SimplePost(url string, params map[string]string) ([]byte, error)

SimplePost 额外处理了http状态码

Types

type ClientConfig

type ClientConfig struct {
	// Timeout http客户端的请求的超时时间
	Timeout time.Duration

	// InsecureSkipVerify http客户端,是否验证服务器端的 certificate chain and host name
	InsecureSkipVerify bool
}

Jump to

Keyboard shortcuts

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