diff --git a/src/clj/http/async/client/headers.clj b/src/clj/http/async/client/headers.clj index 96a65f9..b3f2db8 100644 --- a/src/clj/http/async/client/headers.clj +++ b/src/clj/http/async/client/headers.clj @@ -64,7 +64,8 @@ "Creates cookies from headers." [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 ";")] diff --git a/test/http/async/client/test.clj b/test/http/async/client/test.clj index 92768ac..c1b2965 100644 --- a/test/http/async/client/test.clj +++ b/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))]