Browse files

Allow multiple header values, merge the cookies

  • Loading branch information...
1 parent f416aaa commit 6becb1a805f25ee5a05490b08b56ba750a57c5c8 @tomjack tomjack committed Aug 31, 2009
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/clojure/http/client.clj
@@ -63,7 +63,7 @@ or the error stream of connection, whichever is appropriate."
"Returns a map of the response headers from 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
@@ -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.