ngrunwald / ring-middleware-format

Ring middleware for parsing parameters and emitting responses in JSON or other formats
163 stars 49 forks source link

Charset is not extracted from "Content-Type" header #70

Open alexander-yakushev opened 6 years ago

alexander-yakushev commented 6 years ago

I pass a header content-type: application/json; charset=utf-8 in the HTTP request, but the lib ignores it and decides to instead infer the encoding which sometimes leads to :body becoming garbage.

I believe this function should do (get-in req [:headers "content-type"], not (get req :content-type). Or is there something else going on? In https://github.com/ngrunwald/ring-middleware-format/blob/master/src/ring/middleware/format_params.clj#L32

Deraen commented 6 years ago

Ring used to add content-type to the request map: https://github.com/ring-clojure/ring/blob/master/SPEC#L82

As it has been deprecated, maybe new Ring no longer does this?

Muuntaja reads request content-type first and then reads the header directly: https://github.com/metosin/muuntaja/blob/master/src/clj/muuntaja/core.clj#L124