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
{{ message }}
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.
Expressjs appends charset to content-type, and afaict this confuses the KVLT from-content-type middleware.
My understanding is Express's behavior here isn't exactly standard, but it is allowed by browsers historically (or even required for legacy browsers to work expressjs/express#2238, or to mitigate a security vuln expressjs/express#2921. whatever.)
I couldn't find a way to work around from the Express side easily, so I had to do this super weird thing to make it work:
kvlt should correctly handle that case, but doesn't. In the short-term, I think adding :as :application/transit+json to your request maps will allow you to just (defmethod from-content-type :application/transit+json ...), but that's awkward in other ways. the dispatch fn forfrom-content-type should strip any parameters off of the header value. I think the least impactful change would be something like this:
(defmultifrom-content-type"Used by [[as]] to transform an incoming response. Dispatches on `:content-type`' header, as a namespace-qualified keyword (e.g. `:application/edn`). The input and output are the top-level response map, not only the response body. The default implementation (i.e. unrecognized content-type) returns the response map unmodified."
(fn [resp]
(some-> resp (header:content-type) (str/split#" ") first keyword)))
I'm not really actively working on this project, so it may get fixed faster if you submit a PR.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Expressjs appends charset to content-type, and afaict this confuses the KVLT from-content-type middleware.
My understanding is Express's behavior here isn't exactly standard, but it is allowed by browsers historically (or even required for legacy browsers to work expressjs/express#2238, or to mitigate a security vuln expressjs/express#2921. whatever.)
I couldn't find a way to work around from the Express side easily, so I had to do this super weird thing to make it work:
It caused all manner of issues because things like capitalization and whitespace start to matter when going out of band of the abstractions like this.
The text was updated successfully, but these errors were encountered: