MCPcopy Create free account
hub / github.com/chainreactors/spray / NewClient

Function NewClient

core/ihttp/client.go:34–81  ·  view source on GitHub ↗
(config *ClientConfig)

Source from the content-addressed store, hash-verified

32)
33
34func NewClient(config *ClientConfig) *Client {
35 var client *Client
36
37 if config.Type == FAST {
38 client = &Client{
39 fastClient: &fasthttp.Client{
40 TLSConfig: &tls.Config{
41 Renegotiation: tls.RenegotiateOnceAsClient,
42 InsecureSkipVerify: true,
43 },
44 Dial: customDialFunc(config.ProxyClient, config.Timeout),
45 MaxConnsPerHost: config.Thread * 3 / 2,
46 MaxIdleConnDuration: config.Timeout,
47 //MaxConnWaitTimeout: time.Duration(timeout) * time.Second,
48 ReadTimeout: config.Timeout,
49 WriteTimeout: config.Timeout,
50 ReadBufferSize: 16384, // 16k
51 MaxResponseBodySize: int(DefaultMaxBodySize),
52 NoDefaultUserAgentHeader: true,
53 DisablePathNormalizing: true,
54 DisableHeaderNamesNormalizing: true,
55 },
56 ClientConfig: config,
57 }
58 } else {
59 client = &Client{
60 standardClient: &http.Client{
61 Transport: &http.Transport{
62 DialContext: config.ProxyClient,
63 TLSClientConfig: &tls.Config{
64 Renegotiation: tls.RenegotiateNever,
65 InsecureSkipVerify: true,
66 },
67 TLSHandshakeTimeout: config.Timeout,
68 MaxConnsPerHost: config.Thread * 3 / 2,
69 IdleConnTimeout: config.Timeout,
70 ReadBufferSize: 16384, // 16k
71 },
72 Timeout: config.Timeout,
73 CheckRedirect: func(req *http.Request, via []*http.Request) error {
74 return http.ErrUseLastResponse
75 },
76 },
77 ClientConfig: config,
78 }
79 }
80 return client
81}
82
83type ClientConfig struct {
84 Type int

Callers 2

NewBrutePoolFunction · 0.92
NewCheckPoolFunction · 0.92

Calls 1

customDialFuncFunction · 0.85

Tested by

no test coverage detected