14

I've just started learning Clojure and am struggling with the API changes over the past few years. In particular, in 1.2 there was an http-agent function in contrib which allowed for really simple HTTP requests:

 (http-agent "http..." :method "POST" :body "foo=1") 

This function was removed and it seems that now you should either use clojure.java.io or a 3rd party solution like http-kit or clj-http.

I'm really surprised as java.io seems much lower-level and loses the simplicity or http-agent and making http requests seems like something that should be in the core set of libraries (I realise this is very subjective).

What's the rationale for the removal of http-agent? Did it not fit with a core philosophy of Clojure? And what are recommendations for the best library to use for basic HTTP requests?

1 Answer 1

13

I cannot make authoritative statements about the reasons why any particular part of old contrib failed to make it into the new contrib, but in general things were moved over when sufficiently many people were interested, including some able and willing to maintain the new libraries. Perhaps in this case there simply wasn't enough interest.

Additionally, it is extremely straightforward to build Clojure projects on top of multiple libraries and it is not clear that the presence of an http client library in the core set of libraries or the contrib would make things any simpler and/or easier for developers than they are now, with excellent options available in the wider ecosystem.

As for particular examples of such excellent options, I'd point you towards clj-http and http.async.client (in alphabetical order; which one is appropriate depends on whether you'd benefit from firing off your requests asynchronously).

Sign up to request clarification or add additional context in comments.

1 Comment

Michal, many thanks for this answer. My question is borne out of ignorance of the Clojure environment and your response will take me another step further to understanding this. Thanks also for the recommendations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.