> OkHttp 5 - Breaking: Drop support for Kotlin ...
# squarelibraries
u
OkHttp 5 - Breaking: Drop support for Kotlin Multiplatform.
Oh crap, really?
I'm comfortable to okhttp being just a JVM networking engine, i.e. what
URLSession
is on ios and have a "retrofit/ktor" sit ontop and provide a hig level api, however what sort of bothers me about this is that I have a bunch of logic in `Interceptor`s, whole auth layers etc. Does this mean I should push this sort of middleware to the higher level layer and roll my own middleware api? I don't like having auth done multiple times 😕.
e
it never made it out of alpha
so no change for okhttp 4.x or earlier consumers
u
yea I'm aware, I was just counting on this to share my auth layer/interceptors
e
ah. then it's the same as the present situation. you can try sharing across platforms with logic in ktor
u
hm, ktor wraps okhttps auth?
I thought it was out of scope, same as retrofit
e
ktor can use okhttp as a client engine
u
right but
Authenticator
is a okhttp type, how to bring that to multuplatform, does ktor have the equivalent?
u
not if I follow, I mean the part that attached auth tokens & refreshes tokens on 401 & retries the offending requests again
e
ah that's the server side above. client is https://ktor.io/docs/client-auth.html#configure_authentication
🎉 1
u
I see, that's what I was looking for .. okay so my original intuiton was correct, move it to the higher abstraction, but ktor already has it, gotcha, thanks!
y
Notes from @jessewilson > > Breaking: Drop support for Kotlin Multiplatform. > > We planned to support multiplatform in OkHttp 5.0, but after building it, we weren't happy with the implementation trade-offs. We can't use our HTTP client engine on Kotlin/JS, and we weren't prepared to build a TLS API for Kotlin/Native. > > We'd prefer a multiplatform HTTP client API that's backed by OkHttp on Android and JVM, and other engines on other platforms. Ktor does this pretty well today!
👍 2
u
yea.. I think it makes sense, I was surprised by the original announcement you guys want to do this
y
There are bits that OkHttp does really well, some of the URL parsing that could be reusable KMP. And a desire to unblock libraries like coil. They unblocked themselves instead of waiting, ktor as the API which is not vaporware is the right choice for KMP clients.
1
t
Is there some kind of generic doc about migrating from okhttp to ktor? Specially all the single instance + newbuilder approach and all the different interceptors.
u
I'd need that as well, since I have bunch of (shallow copied) okhttp instances, which attach differenr interceptors - i.e. loggedOutOkHttp/loggedInWithAuthenticatorOkhttp etc
Soo, should I really start ditching retrofit in favor of ktor? No hope for retrofit going kmp?
j
Hope
u
Does it still make sense if auth is okhttp and that won't be shareable?
j
@ursus Can always try ktorfit. https://foso.github.io/Ktorfit/ So that already work in KMP. I love Okhttp but more and more I leaning to run Ktor both in KMP and JVM only projects.
y
Ktor will use OkHttp if you include ktor-okhttp. Which is worth doing. Otherwise on android you'll be losing features.
303 Views