1

I basically have a proxy that has a username and password. I was wondering how to make an HTTP request with the library net/http, but with an HTTP proxy with authentication.

Thank you!

  • 1
    Does this answer your question? [Go http proxy with auth](https://stackoverflow.com/questions/51175487/go-http-proxy-with-auth) – larsks Apr 17 '22 at 21:42

1 Answers1

2

What about something like

&http.Client{
  Transport: &http.Transport{
    Proxy: http.ProxyURL(&url.URL{
      Scheme: "http",
      User:   url.UserPassword("login", "password"),
      Host:   "IP:PORT",
    }),
  },
}
Novy
  • 1,436
  • 1
  • 14
  • 26