Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pros and Cons of Clojure http client libraries

Tags:

java

http

clojure

I am trying to write a http file downloader in Clojure, and in one of my other questions, someone commented that using a dedicated http client library is better than coding with Clojure's and Java's own api. I did some research and found some, but I couldn't figure out features, pros and cons of each. So if some one can explain how they are different and which one is a good match to my project, that would be much appreciated. :-D

Libraries originally in Java, and corresponding Clojure wrappers:

Apache HttpClient and its Clojure wrapper clj-http

Apache HttpAsyncClient and couldn't find any Clojure wrapper.

Netty and Clojure "wrapper" is Aleph, I guess?

Async Http Client and its Clojure wrapper http.async.client

Last but not least, a Clojure library:

http-kit

like image 580
Jay Somedon Avatar asked Aug 10 '13 09:08

Jay Somedon


1 Answers

I can only compare http-kit and clj-http.

clj-http:

  • simple API
  • HTTP client only
  • a wrapper for Apache HttpComponents

http-kit:

  • designed for async
  • HTTP client and server, more powerful
  • client API modeled after clj-http but it adds more abstractions so the cognitive load is higher

If you care about dependencies, http-kit may be a better choice because it is a standalone library with no other dependencies than clojure.core. Because of that it produces smaller uberjars. For a sample HTTP GET project:

clj-http:

1.2M    clj-http-test-0.1.0-SNAPSHOT.jar
6.7M    clj-http-test-0.1.0-SNAPSHOT-standalone.jar

http-kit:

65K     http-kit-test-0.1.0-SNAPSHOT.jar
3.8M    http-kit-test-0.1.0-SNAPSHOT-standalone.jar

On the other hand you may choose clj-http if you prefer to trust the battle tested Apache HttpComponents and potentially better support from bigger Java community.

like image 109
Grzegorz Luczywo Avatar answered Oct 04 '22 12:10

Grzegorz Luczywo