You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(defn-parse-content-type"Parse `s` as an RFC 2616 media type."
[s]
(when-let [m (re-matches#"\s*(([^/]+)/([^ ;]+))\s*(\s*;.*)?" (str s))]
{:content-type (keyword (nth m 1))
:content-type-params
(->> (clojure.string/split (str (nth m 4)) #"\s*;\s*")
(remove clojure.string/blank?)
(map #(clojure.string/split % #"="))
(map (fn [[k v]] [(keyword (clojure.string/lower-case k)) (clojure.string/trim v)]))
(into {}))}))
Some other options:
Wrap w/ a try/catch and let coerce-response-body just hit the default defmethod
Wrap with a try/catch and throw a specific exception about invalid content-type header
Attempt to parse as much as possible such as changing this line to what's below. This will cause the body to be parsed as json still but will ignore the encoding since it couldn't be parsed. (map (fn [[k v]] (when (and k v) [(keyword (clojure.string/lower-case k)) (clojure.string/trim v)])))
The text was updated successfully, but these errors were encountered:
I'm fine closing this one as I could go either way on if this is a real issue or not or what the debatable expected behavior should be.
One of our services was accidentally sending back
application/json; charset: utf8
instead ofapplication/json; charset=utf8
which causes hato to fail:Some other options:
coerce-response-body
just hit the default defmethod(map (fn [[k v]] (when (and k v) [(keyword (clojure.string/lower-case k)) (clojure.string/trim v)])))
The text was updated successfully, but these errors were encountered: