mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
优化client, 关闭path与header的normalizing
This commit is contained in:
parent
fed6fbb3ae
commit
f05fd498be
@ -27,12 +27,15 @@ func NewClient(thread int, timeout int, clientType int) *Client {
|
|||||||
InsecureSkipVerify: true,
|
InsecureSkipVerify: true,
|
||||||
},
|
},
|
||||||
//ReadBufferSize: 20480,
|
//ReadBufferSize: 20480,
|
||||||
MaxConnsPerHost: thread * 2,
|
MaxConnsPerHost: thread * 2,
|
||||||
MaxIdleConnDuration: time.Duration(timeout) * time.Second,
|
MaxIdleConnDuration: time.Duration(timeout) * time.Second,
|
||||||
MaxConnWaitTimeout: time.Duration(timeout) * time.Second,
|
MaxConnWaitTimeout: time.Duration(timeout) * time.Second,
|
||||||
ReadTimeout: time.Duration(timeout) * time.Second,
|
ReadTimeout: time.Duration(timeout) * time.Second,
|
||||||
WriteTimeout: time.Duration(timeout) * time.Second,
|
WriteTimeout: time.Duration(timeout) * time.Second,
|
||||||
MaxResponseBodySize: DefaultMaxBodySize,
|
MaxResponseBodySize: DefaultMaxBodySize,
|
||||||
|
NoDefaultUserAgentHeader: true,
|
||||||
|
DisablePathNormalizing: true,
|
||||||
|
DisableHeaderNamesNormalizing: true,
|
||||||
},
|
},
|
||||||
timeout: time.Duration(timeout) * time.Second,
|
timeout: time.Duration(timeout) * time.Second,
|
||||||
clientType: clientType,
|
clientType: clientType,
|
||||||
@ -50,8 +53,10 @@ func NewClient(thread int, timeout int, clientType int) *Client {
|
|||||||
MaxConnsPerHost: thread,
|
MaxConnsPerHost: thread,
|
||||||
IdleConnTimeout: time.Duration(timeout) * time.Second,
|
IdleConnTimeout: time.Duration(timeout) * time.Second,
|
||||||
},
|
},
|
||||||
Timeout: time.Second * time.Duration(timeout),
|
Timeout: time.Second * time.Duration(timeout),
|
||||||
CheckRedirect: checkRedirect,
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
},
|
},
|
||||||
timeout: time.Duration(timeout) * time.Second,
|
timeout: time.Duration(timeout) * time.Second,
|
||||||
clientType: clientType,
|
clientType: clientType,
|
||||||
@ -94,12 +99,3 @@ func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) {
|
|||||||
return nil, fmt.Errorf("not found client")
|
return nil, fmt.Errorf("not found client")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var MaxRedirects = 0
|
|
||||||
var checkRedirect = func(req *http.Request, via []*http.Request) error {
|
|
||||||
if len(via) > MaxRedirects {
|
|
||||||
return http.ErrUseLastResponse
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user