Do I need to write my own proxy processing code for OkHttp on Android?

We are going to switch our HTTP stack from Apache HttpClient to OkHttp. One piece of code that we have is a broadcast receiver that detects changes in the network proxy and manually updates the HttpClient to route HTTP requests through this proxy.

I'm not sure if I still need to handle this manually with OkHttp?

Quote from the docs setProxySelector:

If this parameter is not set, the system proxy server selector will be used by default.

Looking at [0], it looks like we're covered, since OkHttp uses the system selector by default, which, in turn, allows you to return the properties of the proxy system back to OkHttp routes?

[0] http://docs.oracle.com/javase/7/docs/technotes/guides/net/proxies.html

+4
source share
1 answer

No. OkHttp automatically uses the appropriate proxy. You can check it yourself Charles , following these instructions .

+1
source

Source: https://habr.com/ru/post/1570285/


All Articles