Answer the question
In order to leave comments, you need to log in
How to correctly set a proxy like user:[email protected]:port?
How to correctly set a proxy like user:[email protected]:port for http.Client ( Transport ? )
Now I'm trying to set it like this:
usr := url.UserPassword("log", "pass")
u := url.URL{
User: usr,
Host: "host",
}
tr.Proxy = http.ProxyURL(&u)
{
"Scheme":"Тутлогин",
"Opaque":"пароль@ип:порт",
"User":null,
"Host":"",
"Path":"",
"RawPath":"",
"ForceQuery":false,
"RawQuery":"",
"Fragment":""
}
Answer the question
In order to leave comments, you need to log in
Omitted error handling.
import (
"net/http"
"net/url"
)
func main() {
urlStr := "http://..."
request, err := http.NewRequest("GET", urlStr, nil)
proxyURL, err := url.Parse("http://username:[email protected]:port")
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
client := &http.Client{
Transport: transport,
}
response, err := client.Do(request)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question