Skip to content

Commit

Permalink
Allow multiple header values, merge the cookies
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Jack committed Aug 31, 2009
1 parent f416aaa commit 6becb1a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/clojure/http/client.clj
Expand Up @@ -63,7 +63,7 @@ or the error stream of connection, whichever is appropriate."
"Returns a map of the response headers from connection."
[connection]
(let [hs (.getHeaderFields connection)]
(into {} (for [[k v] hs :when k] [k (first v)]))))
(into {} (for [[k v] hs :when k] [(keyword (.toLowerCase k)) (seq v)]))))

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

0 comments on commit 6becb1a

Please sign in to comment.