Recommended lightweight http client for java 8

I am working on an updater app for my game client.

I have been using springs web-flux as a HTTP client for some minor things unrelated.

I just discovered that this may no longer be feasible since it drags in about two dozen transient files, duplicates all my other dependencies and includes them in my zip under a folder off my root and also screws up my scripts. (Basically, it builds a fat jar inside my normal project jar inside my zip distribution)

I will be testing some gradle related changes to see if I can stop it but I don’t think I can based off what I have been reading.

If I was using openJDK 9+ I could just use the built in java HTTP client but I don’t plan to switch until April of next year.

To cut to the chase, any suggestions on a small, simple library to use for now?

I have looked a Apache and Unirest and would like an alternative.

HTTP client? What is the problem with using Http(s)URLConnection ?

Apache HTTP is good. But also you could just use the Java one. I guess it is ok, even though it has been redesigned in Java 9, was it? One of their redesign goals was to be at least as good as the Apache one. Your needs don’t sound awfully complex so I guess you are fine with whatever…?

I always use HttpClient.

Like others have mentioned, I just use the built in Java client until it doesn’t work for me for some reason. (Though I can 90% of the time make it work even then.)

It’s simple to use and gets the job done with no extra dependencies. Been there since the beginning, basically.

Edit: for example, simple to use… if you just need to get the content of some URL…

URLConnection conn = new URL("someUrl").openConnection();

…handles a few different protocols, too.

It’s only when you need to worry about different response codes, or posting instead of “GET”, etc. that you need to go to the URLConnection subclasses directly and/or cast the result of openConnection.

1 Like

Ok, thanks guys.

I didn’t find the classes when trying to auto complete in netbeans until your posts cleared up my mistake. First time with java and Http(s)URLConnection.

Its really no different than webflux except you have to setup everything yourself. Thankfully I setup my objects to be JSON compatible using toString so was an easy change.

I found out the biggest problem with spring is I was using their dependencies plugin. It works real nice if you are building a web server but when trying to just use webflux theres just to much overhead.

That thing dragged in dam near 50 jars. I only realized it because the updater prints out a file that lists all depends that are able to be updated.

Successfully implemented synchronous so I will push on to see if I can do asynchronous now.

Thanks again.