Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fixes issue when parsing some cookies #30

merged 1 commit into from

2 participants


The current create-cookies function assumes that the 'set-cookie' header is always a vector.

I find out that this is not always true. If the response from the server contains a single 'set-cookie', the 'set-cookie' entry in the header map will be a string instead of a vector. This generates a java exception when the create-cookies function is called.

I wrote a new test to catch this scenario and changed the 'create-cookie' function to handle it.

Disclamer: I am Clojure newbie! I hope that everything is okay!

Thanks for the work you put on this library.

Cesar Canassa


Thank you for the patch!

I've already merged it to development branch and pushed snapshot to clojars.
Will create release for it later today.

@neotyk neotyk merged commit e139a02 into cch1:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 24, 2012
  1. @canassa
This page is out of date. Refresh to see the latest.
3  src/clj/http/async/client/headers.clj
@@ -64,7 +64,8 @@
"Creates cookies from headers."
(if (contains? headers :set-cookie)
- (for [cookie-string (:set-cookie headers)]
+ (for [cookie-string (let [set-cookie (:set-cookie headers)]
+ (if (string? set-cookie) (vector set-cookie) set-cookie))]
(let [name-token (atom true)]
(into {}
(for [#^String cookie (.split cookie-string ";")]
12 test/http/async/client/test.clj
@@ -136,7 +136,7 @@
constraint (Constraint.)
mapping (ConstraintMapping.)
security (ConstraintSecurityHandler.)]
(.addBean srv loginSrv)
(doto constraint
(.setName Constraint/__BASIC_AUTH)
@@ -481,6 +481,16 @@
(is (thrown-with-msg? RuntimeException #"Too many connections 1" (GET client url)))
(is (not (failed? (await r1)))))))
+(deftest single-set-cookie
+ (let [resp (GET *client* "http://localhost:8123/cookie")
+ cookie (first (cookies resp))
+ header (headers resp)]
+ (is (string? (:set-cookie header)))
+ (is (= (:name cookie) "foo"))
+ (is (= (:value cookie) "bar"))))
(deftest await-string
(let [resp (GET *client* "http://localhost:8123/stream")
body (string (await resp))]
Something went wrong with that request. Please try again.