Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are MimeTypes lowercase / case insensitive?

Tags:

We have some code that processes messages based on mimetypes, which requires matching them. A cursory glance suggests are all lower-case, which leads one to wonder if:

  • they are so by convention, or
  • is that part of the spec? (a search of RFC 2045/2046 for upper/lower case etc. did not return any hits)

So, can the case insensitive compare be omitted for the tiny performance boost ?

like image 952
Kumar Avatar asked Oct 13 '12 01:10

Kumar


People also ask

What is case-insensitive example?

For example, the Google Search engine is basically case-insensitive, with no option for case-sensitive search.

Is uppercase case-sensitive?

Text or typed input that is sensitive to capitalization of letters. For example, "Computer" and "computer" are two different words because the "C" is uppercase in the first example and lowercase in the second example.

What is case-insensitive text?

If something is case-insensitive, it does not distinguish between uppercase and lowercase characters. It is the opposite of case-sensitive, in which the case of each letter matters.

What is the difference between MIME type and Content-Type?

The only difference being the optional character set encoding. If the contentType does not include an optional character set encoding then it is identical to a mimeType. Otherwise, the mimeType is the data prior to the character set encoding sequence.


1 Answers

MIME types are case insensitive. They are lowercase by convention only.

RFC 2045 says: "The type, subtype, and parameter names are not case sensitive." If you have a MIME type of text/plain that's a type of text and a subtype of plain. So, per the spec, these are not case sensitive.

As Cromax notes in a comment, MIME type parameter values may be case-sensitive. See the comment or the spec for details. But if you're matching only the mime type, subtype, or parameter names, they are case insensitive. Anecdotally, most people work with mime type and maybe subtype, and those are case insensitive.

like image 70
Trott Avatar answered Oct 01 '22 19:10

Trott