0

I updated my okhttp to okhttp3 because of vulnerability issue, but the class OkHttpClient doesn't have setProxy now. What should I do? Should I rewrite the code with new one?

Thanks.

Ricky Vene
  • 105
  • 1
  • 11

1 Answers1

1

It seems that in okhttp3, it's using proxy() for the OkHttpClient.Builder. proxy() has the same documentation as setProxy() in older okhttp.

Here are some examples using proxy().

Haoliang
  • 1,184
  • 4
  • 11
  • Thanks @Haoliang I put this, Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.server.com", 8080)); OkHttpClient client = new OkHttpClient.Builder() .proxy(proxy) .build(); – Ricky Vene Jul 02 '22 at 01:46