MCPcopy Index your code
hub / github.com/code-scan/Goal / SetProxy

Method SetProxy

Ghttp/http.go:118–139  ·  view source on GitHub ↗
(proxyUrl string)

Source from the content-addressed store, hash-verified

116}
117
118func (h *Http) SetProxy(proxyUrl string) *Http {
119 u, _ := url.Parse(proxyUrl)
120 switch u.Scheme {
121 case "https":
122 //log.Println("use proxy", u.Scheme)
123 h.HttpTransport.Proxy = http.ProxyURL(u)
124 case "http":
125 //log.Println("use proxy", u.Scheme)
126 h.HttpTransport.Proxy = http.ProxyURL(u)
127 case "socks5":
128 pwd, _ := u.User.Password()
129 auth := proxy.Auth{
130 User: u.User.Username(),
131 Password: pwd,
132 }
133
134 h.SetSocksProxy(u.Host, &auth)
135
136 }
137 return h
138
139}
140func (h *Http) SetSocksProxy(proxyUrl string, auth *proxy.Auth) *Http {
141 baseDialer := &net.Dialer{
142 Timeout: 30 * time.Second,

Callers 4

GetFunction · 0.80
PostFunction · 0.80
TestCookieFunction · 0.80
TestNewReqFunction · 0.80

Calls 1

SetSocksProxyMethod · 0.95

Tested by 2

TestCookieFunction · 0.64
TestNewReqFunction · 0.64