Just released v0.2.2 of HTTP Asynchronous Client.
Featuring following changelog http://bit.ly/hc9dxt
- get-encoding helper works w/o Content-Type header
- upgrade async-http-client to v1.5.0
- exposed more configuration options
- zero byte copy mode
- allow providing your own poll
- allow Asynchronous Connect
- fix seq streaming API
- lots of performance improvements from async-http-client to v1.5.0
Uploaded to clojars http://bit.ly/hVAY8z
Documentation is here: http://bit.ly/epmcMw
Enjoy fresh release,
Hubert.
Thank you for your feedback.
Inline are my answers.
On Feb 9, 2011, at 8:13 AM, Takahiro Hozumi wrote:
> Hi,
> Thank you for the introduction. Here is my little feed back:
> 1. I want to see a example using callbacks.
Documentation on on callbacks can be found here: http://neotyk.github.com/http.async.client/docs.html#sec-1_3_1_2
Please see tests:
status callback: https://github.com/neotyk/http.async.client/blob/master/test/http/async/client/test.clj#L162
headers callback: https://github.com/neotyk/http.async.client/blob/master/test/http/async/client/test.clj#L176
And production code:
body part callback: https://github.com/neotyk/http.async.client/blob/master/src/clj/http/async/client.clj#L106
completion and error callbacks: https://github.com/neotyk/http.async.client/blob/master/src/clj/http/async/client.clj#L118
Also take a look at currently provided callback: https://github.com/neotyk/http.async.client/blob/master/src/clj/http/async/client/request.clj#L65
I'll improve documentation and describe callback a bit better.
https://github.com/neotyk/http.async.client/issues/labels/Docs#issue/12
Though please comment on it if you would like to see something more to be added there except examples.
> 2. Is RequestBuilderWrapper.java necessary? Why not simply use
> RequestBuilder?
Unfortunately it is necessary. The way original RequestBuilder uses generics doesn't work with direct Clojure invocations.
> 3. I prefer reify or defrecord to proxy for performance reason, when
> implement interface.
I've created an issue to replace proxy usage with reify, thank you for the tip.
https://github.com/neotyk/http.async.client/issues#issue/13
> 4. I think hash-map is more suitable rather than cond in convert-
> method function.
+1 https://github.com/neotyk/http.async.client/issues/issue/14
>
> Thanks.
>
Thank you,
Hubert.
>
> On 2月8日, 午前3:30, Hubert Iwaniuk <neo...@kungfoo.pl> wrote:
>> Hi All,
>>
>> Just released v0.2.2 of HTTP Asynchronous Client.
>>
>> Featuring following changeloghttp://bit.ly/hc9dxt
>>
>> - get-encoding helper works w/o Content-Type header
>> - upgrade async-http-client to v1.5.0
>> - exposed more configuration options
>> - zero byte copy mode
>> - allow providing your own poll
>> - allow Asynchronous Connect
>> - fix seq streaming API
>> - lots of performance improvements from async-http-client to v1.5.0
>>
>> Uploaded to clojarshttp://bit.ly/hVAY8z
>>
>> Documentation is here:http://bit.ly/epmcMw
>>
>> Enjoy fresh release,
>> Hubert.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
Glad you like it!
What would like to see in upcoming releases of http.async.client?
Thank you!
Cheers,
Hubert.
You need to close the client once you are done with it.
Please see "Managing http.async.client" of manual especially "Closing http.async.client" http://neotyk.github.com/http.async.client/docs.html#sec-1_2_6_11
HTH,
Hubert.
Please see following code:
(ns twitter-stream
(:require [http.async.client :as c]
[org.danlarkin.json :as j]))
(def u "...")
(def p "...")
(defn -main []
(let [resp (c/stream-seq :get "http://stream.twitter.com/1/statuses/sample.json"
:auth {:user "ahcclj" :password "ahcclj11"}
:timeout -1)]
(doseq [twit-str (c/string resp)]
(try
(let [twit (j/decode-from-str twit-str)
u (get-in twit [:user :screen_name])
t (:text twit)]
(if (or (nil? u) (nil? t))
(println "Twit not decoded properly: " twit)
(println u "=>" t)))
(catch Exception e
(println "Failed to parse: " twit-str (.getMessage e))))))
(c/close))
You don't need to create new client.
Now that I think of it it probably is a bug that one client is started by default.
HTH,
Hubert.
oh man, there was just missing "c/close", silly me ;)
now this function works perfectly:
<code>
(defn test-working
[]
(let [response (c/GET "http://github.com/neotyk/http.async.client/")]
(c/await response)
(println (c/string response))
(c/close)))
</code
thanks for help, now back to my screen scraper :)
Br,
Rob