ahc-clj is Async Http Client for Clojure.
It is based on Asynchronous Http Client for Java which runs on top of Netty Project.
There are three modes in witch it works:
- Asynchronous operations
When you do:
(GET url)
Result will be a clojure.core/promise that will be delivered once response is completed. This promise is a map that contains following keys:
- :status - lazy map of status fields
- :code - response code
- :msg - response message
- :protocol - protocol with version
- :major - major version of protocol
- :minor - minor version of protocol
- :headers - lazy map of headers where header names are keyworded, like :server for example
- :body - body of response, this is ByteArrayOutputStream, but you have convenience functions to convert it to string for example
- :error if there was an error you will find Throwable here
- :status - lazy map of status fields
- Streaming
When you do:
(stream-seq :get url)
Result will be ref to a map that contains promises for different stages of request processing as well as contents of map returned by functions like GET except :body will be lazy sequence of ByteArrayOutputStreams.
- Raw mode
This allows you to provide callbacks that will get triggered on Http
Response events like:
- received status line,
- received headers,
- received body part,
- completed request,
- handle error.
ahc-clj is distributed under Apache License, Version 2.0.
Clojure 1.2
See docs. Also autodoc is available.
List of tasks to do.