Suppose I create my own implementation of an Interceptor from OkHttp3:
class MyInterceptor: Interceptor {
private val gson = Gson()
override fun intercept(chain: Interceptor.Chain): Response {
val request = chain.request()
// Will this block the main thread?
val response = chain.proceed(request)
return Response.Builder()
.code(200)
.request(request)
.protocol(Protocol.HTTP_1_1)
.message("OK")
.body(
gson.toJson("foo").toResponseBody("application/json".toMediaType())
)
.build()
}
}
Will the call to chain.proceed() block the main thread? This seems counter-intuitive to what is provided Retrofit's support of suspend functions, which is built on top of OkHttp3. Because I've chosen to use an interceptor, do I now lose that async support?