Open jsyrjala opened 5 years ago
Hmm okay, we need to figure out what rename-keys
uses that the HeaderMap needs to implement in order to get it to work.
rename-keys
uses assoc
internally. assoc
behaves like this: HeaderMap converts keyword keys to Pascal cased string keys. So maybe this is just a feature of HeaderMap.
(require 'clj-http.headers)
(def a (into (clj-http.headers/header-map) {"Foo" "Bar"}) )
(assoc a :foo "baz")
=> {"Foo" "baz"}
(assoc a :quux-xyz "baz")
=> {"Foo" "Bar", "Quux-Xyz" "baz"}
(assoc a "foob" "baz")
=> {"Foo" "Bar", "foob" "baz"}
Anyways, you can use (into {} ...)
to convert HeaderMap to normal Clojure data structure.
(def a (into (clj-http.headers/header-map) {"Foo" "Bar"}) )
(def b (into {} a))
(clojure.set/rename-keys b {"Foo" :foo})
=> {:foo "Bar"}
Maps returned by header-map (HeaderMap instance) are not fully compatible with normal Clojure maps. These maps are part of the clj-http reponse data.
Not sure what if anything should be done to fix this.