Skip to content

Commit 6becb1a

Browse files
author
Thomas Jack
committed
Allow multiple header values, merge the cookies
1 parent f416aaa commit 6becb1a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/clojure/http/client.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ or the error stream of connection, whichever is appropriate."
6363
"Returns a map of the response headers from connection."
6464
[connection]
6565
(let [hs (.getHeaderFields connection)]
66-
(into {} (for [[k v] hs :when k] [k (first v)]))))
66+
(into {} (for [[k v] hs :when k] [(keyword (.toLowerCase k)) (seq v)]))))
6767

6868
(defn- parse-cookies
6969
"Returns a map of cookies when given the Set-Cookie string sent
@@ -111,8 +111,8 @@ by a server."
111111
:code (.getResponseCode connection)
112112
:msg (.getResponseMessage connection)
113113
:method method
114-
:headers (dissoc headers "Set-Cookie")
114+
:headers (dissoc headers :set-cookie)
115115
;; This correctly implements case-insensitive lookup.
116116
:get-header #(.getHeaderField connection (as-str %))
117-
:cookies (parse-cookies (headers "Set-Cookie"))
117+
:cookies (apply merge (map parse-cookies (headers :set-cookie)))
118118
:url (str (.getURL connection))})))

0 commit comments

Comments
 (0)