Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var NewClient = func(conf *configs.HTTPTaskConfig, proxyMap map[string]string) Client { cj, err := cookiejar.New(nil) if err != nil { logger.Errorf("create cookiejar failed: %v", err) } dialer := net.Dialer{ Timeout: conf.Timeout, } transport := &http.Transport{ MaxResponseHeaderBytes: int64(conf.BufferSize), DisableKeepAlives: true, TLSClientConfig: &tls.Config{ InsecureSkipVerify: conf.InsecureSkipVerify, Renegotiation: tls.RenegotiateFreelyAsClient, }, Proxy: func(_ *http.Request) (*url.URL, error) { if conf.Proxy != "" { return url.Parse(conf.Proxy) } return nil, nil }, DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { network = "tcp" switch conf.TargetIPType { case configs.IPv4: network = "tcp4" case configs.IPv6: network = "tcp6" } logger.Debugf("http dial with network: %s", network) if len(proxyMap) > 0 { host, port, err := net.SplitHostPort(addr) if err != nil { logger.Errorf("parse addr %s failed: %v", addr, err) host = addr } if proxyIP, ok := proxyMap[host]; ok { addr = net.JoinHostPort(proxyIP, port) } } return dialer.DialContext(ctx, network, addr) }, } client := &http.Client{ Transport: transport, Jar: cj, Timeout: conf.GetTimeout(), } return client }
NewClient proxyMap代理配置 key: host value: proxy ip, 如{"example.com": "127.0.0.1"}
Functions ¶
Types ¶
type Event ¶
type Event struct { *tasks.Event URL string Index int Steps int Method string ResponseCode int Message string Charset string ContentLength int MediaType string ResolvedIP string }
func (*Event) FailFromError ¶
Click to show internal directories.
Click to hide internal directories.