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
@ -33,6 +33,9 @@ func NewClient(thread int, timeout int, clientType int) *Client {
|
||||
ReadTimeout: time.Duration(timeout) * time.Second,
|
||||
WriteTimeout: time.Duration(timeout) * time.Second,
|
||||
MaxResponseBodySize: DefaultMaxBodySize,
|
||||
NoDefaultUserAgentHeader: true,
|
||||
DisablePathNormalizing: true,
|
||||
DisableHeaderNamesNormalizing: true,
|
||||
},
|
||||
timeout: time.Duration(timeout) * time.Second,
|
||||
clientType: clientType,
|
||||
@ -51,7 +54,9 @@ func NewClient(thread int, timeout int, clientType int) *Client {
|
||||
IdleConnTimeout: time.Duration(timeout) * time.Second,
|
||||
},
|
||||
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,
|
||||
clientType: clientType,
|
||||
@ -94,12 +99,3 @@ func (c *Client) Do(ctx context.Context, req *Request) (*Response, error) {
|
||||
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