优化client, 关闭path与header的normalizing

This commit is contained in:
M09Ic 2022-11-29 22:00:40 +08:00
parent fed6fbb3ae
commit f05fd498be

View File

@ -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
}