https://kotlinlang.org logo
#ktor
Title
# ktor
v

Vivek Modi

04/13/2022, 11:00 AM
Hey what is d/w Android and OkHttp in HttpClient in ktor?
a

Aleksei Tirman [JB]

04/13/2022, 11:18 AM
What do you mean?
v

Vivek Modi

04/13/2022, 11:20 AM
a

Aleksei Tirman [JB]

04/13/2022, 11:21 AM
What is d/w?
v

Vivek Modi

04/13/2022, 11:22 AM
difference between
What is the difference between
Android
and
OkHttp
in
HttpClient
? I added example as well
Copy code
val client = HttpClient(Android)
or
Copy code
val client = HttpClient(OkHttp)
a

Aleksei Tirman [JB]

04/13/2022, 11:24 AM
The difference is in the underlying implementation. The Android engine uses HttpURLConnection and the OkHttp engine uses the OkHttp client.
v

Vivek Modi

04/13/2022, 11:27 AM
So which one you prefer to use
Android
or
OkHttp
? I want to implement interceptor and authenticator as well.
a

Aleksei Tirman [JB]

04/13/2022, 11:31 AM
Both engines allow you to do it. I’d prefer using OkHttp because there are more options for configuring an underlying HTTP client.
v

Vivek Modi

04/13/2022, 11:36 AM
thanks a million. For your suggestion. I tried
OkHttp
in my KMM module. I am getting this error. Can you please look this issue and guide me. Thanks
a

Aleksei Tirman [JB]

04/13/2022, 11:39 AM
He was first :)
v

Vivek Modi

04/13/2022, 11:40 AM
great thanks a million.
g

gildor

04/14/2022, 3:19 AM
I really don’t like that this engine has name “Android” which is extremely misleading. There is nothing Android specific in it, it works on JVM with no problems, which expected, because it uses Java HttpUrlConnection, not some Android API. I created a change request about it, be free to vote for it, maybe it will cause less confusion https://youtrack.jetbrains.com/issue/KTOR-1013
🙏 1
a

andylamax

04/14/2022, 7:02 AM
You have my upvote. I am with you in this one @gildor