croservices / cro-core

The heart of the Cro library for building distributed systems in Raku, including pipeline composition and TCP support.
https://cro.services/
Artistic License 2.0
27 stars 9 forks source link

Could not parse media type 'application/json; charset=utf-8;' #6

Closed ohmycloud closed 6 years ago

ohmycloud commented 6 years ago

some Server return content-type of application/json; charset=utf-8; instead of application/json; charset=utf-8, and thus lead to media type parse error, See this question on SO, I don't know it is a bug or not.

jnthn commented 6 years ago

Well, the RFC I believe applies here suggests it's a bug in whatever server is producing a media type with a trailing ;. The grammar specified in there doesn't permit it.

However, per Postel's law, we should be liberal in what we accept, and looking at some other media type parsers it seems they choose to allow a trailing ;, so there's precedent for this. Thus I think we should change the parser to allow such mildly malformed media types, for the sake of users who have to deal with servers spitting out such things.