ross.squires ross.squires - 1 month ago 12
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

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

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

Comments