Documentation
¶
Index ¶
- func NewCookies() *cookiejar.Jar
- func NewHeaders() *http.Header
- func ParseCookies(rawurl string, cookies interface{}) *cookiejar.Jar
- func ParseHeaders(headers interface{}) *http.Header
- func SearchStrings(str []string, substr string) int
- type BodyHook
- type CookiesHook
- type DataHook
- type Files
- func (fs *Files) AddField(name, value string)
- func (fs *Files) AddFile(name, fileName, filePath, contentType string)
- func (fs *Files) Del(name string) bool
- func (fs *Files) Encode() (*bytes.Buffer, string, error)
- func (fs *Files) Get(name string) map[string]string
- func (fs *Files) SetField(name, value string)
- func (fs *Files) SetFile(name, fileName, filePath, contentType string)
- type FilesHook
- type HeadersHook
- type Params
- type ParamsHook
- type Request
- type URL
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCookies ¶
func ParseCookies ¶
Types ¶
type Files ¶
type Files struct {
// contains filtered or unexported fields
}
Files结构体
type HeadersHook ¶ added in v1.5.0
type HeadersHook func(any) *http.Header
type Request ¶
type Request struct {
// Params 设置 URL 查询参数.
// 支持的类型 (Accepted types):
// - *url.Params
// - string (e.g. "key=value&a=1")
// - map[string]string
// - map[string][]string
// - map[string]int, map[string][]int
// - map[string]float64, map[string][]float64
// - map[string]interface{} (支持递归解析)
Params any
// Headers 设置请求头.
// 支持的类型 (Accepted types):
// - *http.Header
// - string (e.g. "User-Agent: abc\nAccept: */*")
// - map[string]string
// - map[string][]string
// - map[string]interface{} (值支持 string, int, float64, bool)
// - map[string][]interface{}
Headers any
// Cookies 设置请求 Cookies.
// 支持的类型 (Accepted types):
// - *cookiejar.Jar
// - string (e.g. "name=value; a=1")
// - map[string]string
// - map[string]int
// - map[string]float64
// - map[string]interface{} (值支持 string, int, float64, bool)
Cookies any
// Data 设置表单数据 (application/x-www-form-urlencoded).
// 支持的类型 (Accepted types):
// - *url.Values
// - string (e.g. "key=value&a=1")
// - map[string]string
// - map[string][]string
// - map[string]int, map[string][]int
// - map[string]float64, map[string][]float64
// - map[string]interface{} (支持递归解析)
Data any
// Files 设置上传的文件 (multipart/form-data).
// 支持的类型 (Accepted types):
// - *url.Files
// - map[string]string (key为字段名, value为文件路径. 会自动提取文件名,ContentType默认为空)
Files any
// Json 设置 JSON 请求体 (application/json).
// 支持的类型 (Accepted types):
// - map[string]interface{}
// - struct, array, slice, int, bool, string... (任何可被 json.Marshal 处理的类型)
Json any
// Body 设置原始请求体.
// 支持的类型 (Accepted types):
// - io.Reader
// - []byte
// - string
Body any
Auth []string
Timeout time.Duration
AllowRedirects bool
Proxies string
Verify bool
Cert []string
Stream bool
Ja3 string
RandomJA3 bool
ForceHTTP1 bool
TLSExtensions *http.TLSExtensions
HTTP2Settings *http.HTTP2Settings
// --- 解析中间件 (Hooks) ---
ParamsHook ParamsHook
HeadersHook HeadersHook
CookiesHook CookiesHook
DataHook DataHook
FilesHook FilesHook
BodyHook BodyHook
}
Request 配置请求参数的结构体
func (*Request) GetCookies ¶ added in v1.5.0
GetCookies 获取 Cookies 结构体 注意:解析字符串 Cookies 需要 rawurl 来确定域名,请在 Session 逻辑中传入
func (*Request) GetHeaders ¶ added in v1.5.0
func (req *Request) GetHeaders() *http.Header
GetHeaders 获取 Headers 结构体
type URL ¶
type URL struct {
Scheme string // 协议
User *url.Userinfo // 用户信息
Host string // 地址
Path string // 路径
RawParams string // GET参数
Params *Params // GET参数
RawFragment string // 原始锚点
Fragment string // 锚点
// contains filtered or unexported fields
}
URL结构体
Click to show internal directories.
Click to hide internal directories.