request icon indicating copy to clipboard operation
request copied to clipboard

applyProxy() makes http/https/socks5 connection re-use impossible.

Open sinylei opened this issue 5 years ago • 1 comments

When you set a proxy, applyProxy will recreate a new Transport. So the connection pool cached in original Transport object will be discarded. So I changed applyProxy in request/proxy_go12.go as below and it works very well for me.

func applyProxy(a *Args) (err error) { if a.Proxy == "" { return nil }

u, err := url.Parse(a.Proxy)
if err != nil {
	return err
}
switch u.Scheme {
case "http", "https", "socks5":
	a.Client.Transport.(*http.Transport).Proxy = http.ProxyURL(u)
}
return

}

sinylei avatar Oct 03 '18 02:10 sinylei

@sinylei Feel free to send a pull request.

mozillazg avatar Oct 07 '18 02:10 mozillazg