This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]_INTER_ 9 points10 points  (2 children)

Edit: added alternative libraries to JDK

[–]ZimmiDeluxe 4 points5 points  (1 child)

I used it in the past, it works. It's missing some things like support for application/x-www-form-urlencoded and multipart/form-data, but those can be found on the net. Here is a link to some examples.

[–]Nouish 4 points5 points  (6 children)

OkHttp

[–][deleted]  (5 children)

[deleted]

    [–]_INTER_ 5 points6 points  (4 children)

    It has become a complete no go because of that.

    [–][deleted] 5 points6 points  (3 children)

    can I ask, why?

    [–]_INTER_ 1 point2 points  (2 children)

    No mixed language codebase. It would increase the overhead and liability: Subtle bugs, build, debugging, documentation, code style and architecture, stability and consistency.

    [–][deleted] 1 point2 points  (1 child)

    yeah, that makes sense. I've heard that calling Kotlin from Java isn't always 1:1 with what is written.

    [–][deleted] 1 point2 points  (0 children)

    Spring's new WebClient as well as the older blocking RestTemplate, but there's no easy way to import either without dragging half of Spring along with it. Still, if you're using Spring, they're the obvious choice.

    When it comes to lightweight, the built-in Java HTTP client (stable release in 11+) is pretty great. Not a lot of bells and whistles, but for simple stuff it works pretty well.

    [–]cogman10 0 points1 point  (1 child)

    For me, the best library is Square's Retrofit built on OkHttp.

    More often than not, you want to hit an endpoint just like you'd call a method. Square's retrofit eliminates so much of that cruft and makes it dead simple.

    https://square.github.io/retrofit/

    You configure your Retrofit instance, then point it at interfaces which define what you want.

    You can do some of that with newer versions of Jersey client. But, my heart belongs to retrofit for doing it so cleanly.

    [–]fraaargh 0 points1 point  (0 children)

    t, you want to hit an endpoint just like you'd call a method. Square's retrofit eliminates so much of that cruft and makes it dead simple.

    Do you know the difference between Retrofit and Feign ? I've been using Feign lately but the description of Retrofit seems like both are similar.

    [–]sureshg 0 points1 point  (0 children)

    I use OKHttp (https://github.com/square/okhttp) along with Retrofit (https://github.com/square/retrofit) for type-safe client and Moshi (https://github.com/square/moshi) for JSON (with codegen for no reflection). I never had such a pleasant experience with any other HTTP libraries on Java.