ht

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType = "Content-Type"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(proxyRaw string, timeoutSecond uint, ua UserAgent) *httpClient

NewClient 创建一个http请求的客户端 proxyRaw 代理信息,空值则不使用代理;非空:"socks5://admin:password@192.168.1.2:8888" timeoutSecond 请求超时时间,秒

func NewHeaders

func NewHeaders(ua UserAgent) map[string]string

NewHeaders 创建一个浏览器header UA

func NewProxy

func NewProxy(rawurl string) (*http.Transport, error)

NewProxy 创建一个代理,用于发送请求的时候使用。 NewProxy("socks5://admin:password@192.168.1.2:8888")

func ReadBody added in v0.0.3

func ReadBody(resp *http.Response, err error) ([]byte, error)

ReadBody 读取响应体,丢弃其它内容。

Types

type Method added in v0.0.3

type Method string
const (
	GET    Method = "GET"
	POST   Method = "POST"
	PUT    Method = "PUT"
	DELETE Method = "DELETE"
)

type RequestParams added in v0.0.3

type RequestParams struct {
	Header map[string]string
	Query  map[string]string
	Body   map[string]any
}

func Merge added in v0.0.3

func Merge(global RequestParams, local RequestParams, custom RequestParams) RequestParams

Merge 将 local 合并到 global,然后将 custom 合并到 global ,最后返回 global。

func NewRequestParams added in v0.0.3

func NewRequestParams() RequestParams

type UserAgent added in v0.0.3

type UserAgent string
const (
	UaPcWinMicrosoftEdge   UserAgent = `` /* 134-byte string literal not displayed */
	UaPcWinFirefox         UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0`
	UaPcWinGoogleChrome    UserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36`
	UaPcWin360Browser      UserAgent = `Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36`
	UaPcWinSougouBrowser   UserAgent = `` /* 127-byte string literal not displayed */
	UaAndroidUCBrowser     UserAgent = `` /* 159-byte string literal not displayed */
	UaAndroidHuaWeiBrowser UserAgent = `` /* 134-byte string literal not displayed */
)

Jump to

Keyboard shortcuts

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