request

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MulanPSL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	POST    = "POST"
	GET     = "GET"
	PUT     = "PUT"
	DELETE  = "DELETE"
	OPTIONS = "OPTIONS"

	HTTP       = "HTTP"
	HTTPS      = "HTTPS"
	TCP        = "TCP"
	WEBSOCKET  = "WEBSOCKET"
	WEBSOCKETS = "WEBSOCKETS"

	ErrRequest = -1 // 请求失败
	ErrCheck   = -2 // 校验失败
)
View Source
var CH = make(chan *Response, 1000)
View Source
var ConcurrencyMap = &CMap{
	TN:    0,
	CN:    0,
	mutex: sync.RWMutex{},
}

Functions

This section is empty.

Types

type CMap

type CMap struct {
	TN int
	CN int
	// contains filtered or unexported fields
}

func (*CMap) CNAdd

func (c *CMap) CNAdd(num int)

func (*CMap) CNDel

func (c *CMap) CNDel(num int)

func (*CMap) CNGet

func (c *CMap) CNGet() int

func (*CMap) TNAdd

func (c *CMap) TNAdd(num int)

func (*CMap) TNDel

func (c *CMap) TNDel(num int)

func (*CMap) TNGet

func (c *CMap) TNGet() int

type Request

type Request struct {
	URL       string            // 请求地址
	Scheme    string            // 请求类型 HTTP/ WEBSOCKET/ TCP
	Method    string            // 请求方法 GET/ POST/ PUT/ DELETE/ OPTIONS
	Headers   map[string]string // 请求头 Headers
	Body      string            // 请求体 body
	Cookies   []*http.Cookie
	Verify    func([]byte) bool // 验证的方法
	Timeout   time.Duration     // 请求超时时间
	Debug     bool              // 是否开启Debug模式
	MaxCon    int               // 每个连接的请求数
	SSL       bool              // 证书验证
	Keepalive bool              // 是否开启长连接
	Redirect  bool              // 是否重定向

	GlobFun func(http.Response) map[string]any // 全局变量
	// contains filtered or unexported fields
}

func (*Request) Print

func (r *Request) Print()

Print 格式化打印

func (*Request) SetBody

func (r *Request) SetBody() (body io.Reader)

SetBody 格式化请求体

func (*Request) SetHeaders

func (r *Request) SetHeaders() map[string]string

SetHeaders 设置请求头

type Response

type Response struct {
	ChanID        int  // 消息ID
	Time          int  // 请求时间 纳秒
	IsSucceed     bool // 是否请求成功
	StatusCode    int
	ReceivedBytes int
	Cookies       []*http.Cookie
}

func HttpClient

func HttpClient(request *Request) *Response

Jump to

Keyboard shortcuts

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