- Notifications
You must be signed in to change notification settings - Fork9.2k
Open
Description
Call.Factory is the correct API for clients, that allows intercetping calls toCall.Factory.newCall()
. However it's not commonly used and does lose some features such as newBuilder().
I'm suggesting a new API for Call.Factory.Interceptor that will be part of OkHttpClient.Builder and allow replacing the Call instance.
Uses
- Tracing, which typically requires the calling thread for context
- Bridging - seehttps://github.com/google/cronet-transport-for-okhttp?tab=readme-ov-file#setting-up-the-library
- Delaying requests - in the case of Android 15 we may want to fast fail or delay requests while networking is blocked
- redirecting requests to other clients -https://github.com/google/horologist/blob/e24165ecaf9426f487014f2675b6ae4226fc86ca/network-awareness/okhttp/src/main/java/com/google/android/horologist/networks/okhttp/NetworkSelectingCallFactory.kt#L54