Reputation: 150972
I noticed that sometimes the content-type
header of a request (e.g., made by Firefox) does not only contain information on the MIME type, but also on the encoding.
E.g., when sending JSON using AJAX instead of
application/json
(what I expected) Firefox sent:
application/json; charset=UTF-8
I have a number of questions on this behavior:
charset
value) could happen?application/json
always come first, or may the values appear in random order (i.e., could it also be charset=UTF-8; application/json
)?;
?contentType === 'application/json || contentType.startsWith('application/json;')
?PS: For question #4, I created a separate question. See Get an entire string or a substring, depending on a specific character
Upvotes: 0
Views: 233
Reputation: 176006
See the HTTP 1.1 RFC
3.7 Media Types
HTTP uses Internet Media Types [17] in the Content-Type (section 14.17) and Accept (section 14.1) header fields in order to provide open and extensible data typing and type negotiation.
media-type = type "/" subtype *( ";" parameter ) type = token subtype = token Parameters MAY follow the type/subtype in the form of attribute/value pairs (as defined in section 3.6).
So
;
Upvotes: 1