Hi *

Just release first version of Async Http Client for Clojure.
http://clojars.org/ahc-clj

This is async http client that is backed by Async Http Client 
http://bit.ly/aUctdM which by default runs on top of Netty.

General documentation on project is available here: 
http://neotyk.github.com/ahc-clj/
More detailed docs: http://neotyk.github.com/ahc-clj/docs.html
Autodoc: http://neotyk.github.com/ahc-clj/autodoc/
Code: http://github.com/neotyk/ahc-clj

Two basic examples of usage:

(let [resp (GET "<your url>" {:query {:param-name "some-value}})
             status (:status @resp)
             headers (:headers @resp)
             body (:body @resp)]
     (println (:code status))
     (println (apply str (map char body))))

(let [stream (ref #{})
        resp (STREAM :get "<your url>"
                                    (fn [state bytes]
                                       (if (not (empty? bytes))
                                          (let [p (apply str (map char bytes))]
                                             (dosync (alter stream conj p)))
                                           (println "Empty body part 
received."))))]
     ; do something to @stream
     ; @resp will not get delivered until streaming is done
     )

In first example resp is a promise that is delivered once response is received.
Second example is showing how to consume a HTTP Stream, note that it is 
collecting body parts, which is not necessary.
You can provide a callback that will not collect those parts but just acts on 
one that was currently received.

Next releases should expose more configuration body streaming from client to 
server, multipart support.

I hope you'll like it,
Hubert.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to