[ANN] http.async.client v0.2.2 released

132 views
Skip to first unread message

Hubert Iwaniuk

unread,
Feb 7, 2011, 1:30:38 PM2/7/11
to asynchttpclient, Clojure
Hi All,

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.

Takahiro Hozumi

unread,
Feb 9, 2011, 2:13:04 AM2/9/11
to Clojure
Hi,
Thank you for the introduction. Here is my little feed back:
1. I want to see a example using callbacks.
2. Is RequestBuilderWrapper.java necessary? Why not simply use
RequestBuilder?
3. I prefer reify or defrecord to proxy for performance reason, when
implement interface.
4. I think hash-map is more suitable rather than cond in convert-
method function.

Thanks.


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

Hubert Iwaniuk

unread,
Feb 9, 2011, 6:50:23 AM2/9/11
to clo...@googlegroups.com
Hi Takahiro,

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

László Török

unread,
Feb 9, 2011, 6:56:07 AM2/9/11
to clo...@googlegroups.com
Hi,

I've been using http.async.client for my play projects and it seems very promising. Thanks for this awesome library! :)

Las

2011/2/9 Hubert Iwaniuk <neo...@kungfoo.pl>

Hubert Iwaniuk

unread,
Feb 9, 2011, 8:05:19 AM2/9/11
to clo...@googlegroups.com
Hi Las,

Glad you like it!

What would like to see in upcoming releases of http.async.client?


Thank you!

Cheers,
Hubert.

Rob Wolfe

unread,
Feb 9, 2011, 9:29:41 AM2/9/11
to Clojure

On 7 Lut, 19:30, Hubert Iwaniuk <neo...@kungfoo.pl> wrote:
> Hi All,
>
> Just released v0.2.2 of HTTP Asynchronous Client.

I have some problem using this library. Having such simple testing
program:
<code>
(ns test.http
(:require [http.async.client :as c]))

(defn test-http
[]
(println "start")
(let [response (c/GET "http://github.com/neotyk/
http.async.client/")]
(println "await")
(c/await response)
(println "string")
(println (c/string response))
(println "end")))

(defn -main
[]
(println "start-app")
(test-http)
(println "end-app"))
</code>

The output looks as follows:

<output>
$ lein run
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for
further details.
start-app
start
await
string
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/0.7.67</center>
</body>
</html>
end
end-app

[...hangs for ever...]

</output>

But this program never ends, just hangs for ever.
I thought that it might be Windows issue where I first tried it,
but on Linux there is the same problem.

Do you have any idea what I'm doing wrong or where might be the
problem?

My environment looks as follows:
$ java -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode, sharing)
$ lein version
Leiningen 1.4.2 on Java 1.6.0_17 Java HotSpot(TM) Client VM
$ ls lib
async-http-client-1.5.0.jar clojure-1.2.0.jar clojure-
contrib-1.2.0.jar http.async.client-0.2.2.jar netty-3.2.3.Final.jar
slf4j-api-1.6.1.jar
$ uname -a
WindowsNT ww011221 1 5 x86

Br,
Rob

Hubert Iwaniuk

unread,
Feb 9, 2011, 9:51:45 AM2/9/11
to clo...@googlegroups.com
Hi Rob,

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.

Rob Wolfe

unread,
Feb 9, 2011, 10:21:11 AM2/9/11
to Clojure

I created another test function like this:

<code>
(defn test-http-with-close
[]
(println "start")
(binding [*client* (c/create-client)]
(let [response (c/GET "http://github.com/neotyk/
http.async.client/")]
(println "await")
(c/await response)
(println "string")
(println (c/string response)))
(println "close")
(c/close *client*))
(println "end"))
</code>

but it didn't help.
Are you using the same java version, clojure version and the same
versions of all libraries
and it does not hang?
There must be something.

Br,
Robert

Hubert Iwaniuk

unread,
Feb 9, 2011, 12:28:54 PM2/9/11
to clo...@googlegroups.com
Hi Rob,

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.

Rob Wolfe

unread,
Feb 9, 2011, 2:54:04 PM2/9/11
to clo...@googlegroups.com
Hubert Iwaniuk <neo...@kungfoo.pl> writes:

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

Reply all
Reply to author
Forward
0 new messages