mirror of
https://github.com/chainreactors/spray.git
synced 2025-11-05 10:27:38 +00:00
fix standard client null proxy bug
This commit is contained in:
parent
9eb4a13e20
commit
b487e3da15
@ -26,8 +26,9 @@ const (
|
||||
)
|
||||
|
||||
func NewClient(config *ClientConfig) *Client {
|
||||
var client *Client
|
||||
if config.Type == FAST {
|
||||
return &Client{
|
||||
client = &Client{
|
||||
fastClient: &fasthttp.Client{
|
||||
TLSConfig: &tls.Config{
|
||||
Renegotiation: tls.RenegotiateOnceAsClient,
|
||||
@ -48,7 +49,7 @@ func NewClient(config *ClientConfig) *Client {
|
||||
Config: config,
|
||||
}
|
||||
} else {
|
||||
return &Client{
|
||||
client = &Client{
|
||||
standardClient: &http.Client{
|
||||
Transport: &http.Transport{
|
||||
//Proxy: Proxy,
|
||||
@ -60,9 +61,6 @@ func NewClient(config *ClientConfig) *Client {
|
||||
MaxConnsPerHost: config.Thread * 3 / 2,
|
||||
IdleConnTimeout: config.Timeout,
|
||||
ReadBufferSize: 16384, // 16k
|
||||
Proxy: func(_ *http.Request) (*url.URL, error) {
|
||||
return url.Parse(config.ProxyAddr)
|
||||
},
|
||||
},
|
||||
Timeout: config.Timeout,
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
@ -71,7 +69,13 @@ func NewClient(config *ClientConfig) *Client {
|
||||
},
|
||||
Config: config,
|
||||
}
|
||||
if config.ProxyAddr != "" {
|
||||
client.standardClient.Transport.(*http.Transport).Proxy = func(_ *http.Request) (*url.URL, error) {
|
||||
return url.Parse(config.ProxyAddr)
|
||||
}
|
||||
}
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
type ClientConfig struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user