Closed jkk closed 12 years ago
Thanks for reporting this issue.
I'll try to reproduce it. Just to make sure, what version are you at?
I'm using 0.4.0.
I've tried to reproduce it, unfortunately with little luck. Can you please see test extract-empty-body 1
I also modified for testing this issue by wrapping body of this test in (dotimes [_ 100] ..) No luck reproducing it here as well.
Please tell me how your usage is different from one in test extract-empty-body.
I was able to reproduce with a server that does not return a body (headers only). The problem with test extract-empty-body is the presence of await. If you remove the await then the test suite will hang indefinitely. Adding the body delivery in onComplete fixes that problem.
diff --git a/test/http/async/client/test.clj b/test/http/async/client/test.clj
index 6dbae1f..ba91a4a 100644
--- a/test/http/async/client/test.clj
+++ b/test/http/async/client/test.clj
@@ -598,7 +598,7 @@
(deftest extract-empty-body
- (let [resp (await (GET *client* "http://localhost:8123/empty"))]
+ (let [resp (GET *client* "http://localhost:8123/empty")]
(is (nil? (string resp)))))
diff --git a/src/clj/http/async/client/request.clj b/src/clj/http/async/client/request.clj
index a034ff0..3640269 100644
--- a/src/clj/http/async/client/request.clj
+++ b/src/clj/http/async/client/request.clj
@@ -255,7 +255,8 @@
onCompleted [this]
(do
(completed resp)
- (deliver (:done resp) true)))
+ (deliver (:done resp) true)
+ (deliver (:body resp) nil)))
Updated clojars: https://clojars.org/http.async.client Please test with that last snapshot.
Would it be possible to have a non-snapshot release for this fix?
Yes, preparing v0.4.1 release.
v0.4.1. released. Thank you!
I notice you had an apparent fix for this in issue #4, but it's still happening for me, although inconsistently. It seems to happen after repeated calls to
c/GET
that return an empty body.My hackish workaround was to add this to the :completed callback:
Not sure if this "fix" is reliable or whether onCompleted could be called before the body is done being processed.