ring-middleware-format icon indicating copy to clipboard operation
ring-middleware-format copied to clipboard

Charset is not extracted from "Content-Type" header

Open alexander-yakushev opened this issue 6 years ago • 1 comments

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

alexander-yakushev avatar Apr 12 '18 13:04 alexander-yakushev

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

Deraen avatar Apr 15 '18 19:04 Deraen