ross.squires ross.squires - 1 year ago 144
HTTP Question

For OkHttp, Does SSLSocketFactory use SocketFactory first?

I'm currently wanting to use ConnectivityManager.NetworkCallback on Android, hoping to direct all REST calls to a "good" network with OkHttp. While looking at OkHttp's API, should I implement both SocketFactory and SSLSocketFactory to redirect calls to another network, or will SocketFactory be enough?

Answer Source

Yes, OkHttp always starts with a regular socket first. You can see this in

Because connecting to an HTTPS server over an HTTP proxy requires a plaintext CONNECT request, it’s unlikely that any other approach would work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download