https://kotlinlang.org logo
Title
t

tschuchort

03/15/2019, 6:19 PM
What's the preferred library for sending HTTP requests? I don't need anything fancy, just basic cookie/session functionality and minimal setup
d

dalexander

03/15/2019, 6:23 PM
ktor-client if you want to use something kotlin-native. Retrofit is pretty good otherwise. There are a bunch of other Java options out there if one of those doesn’t suit your needs.
t

tschuchort

03/15/2019, 6:26 PM
Which Java library would you recommend? It doesn't have to be Kotlin specific if the Java libraries have better docs
I think retrofit is a bit too involved for what I want to do. I just want to write a small script to automate clicking a button on a website
c

Casey Brooks

03/15/2019, 6:28 PM
Retrofit is a wrapper over OkHttp, which would be my recommendation in that case
But to be honest, I think you’d end up writing less code using Retrofit than you would be using OkHttp directly
👍 1
d

dalexander

03/15/2019, 6:32 PM
If you want the simplest thing possible, try something like the apache fluent http client. Which is a little bit weak overall but easy to get started with IMO. (OkHttp might also be good for that, I haven’t used it directly before).
t

tschuchort

03/15/2019, 6:52 PM
It seems to me that Retrofit is a lot more "enterprise" and requires more setup. I just need to send a login request, then use the returned session cookie to send another http request. I'll take a look at OkHttp
c

Corey Johnson

03/15/2019, 7:49 PM
With Retrofit you just have to set up an interface and a class that creates the service using a builder https://square.github.io/retrofit/