Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference of ContentType and MimeType

As far as I know, they are absolute equal. However, browsing some django docs, I've found this piece of code:

HttpResponse.__init__(content='', mimetype=None, status=200, content_type='text/html')

which surprise me the two getting along each other. The official docs was able to solve the issue in a pratical manner:

content_type is an alias for mimetype. Historically, this parameter was only called mimetype, but since this is actually the value included in the HTTP Content-Type header, it can also include the character set encoding, which makes it more than just a MIME type specification. If mimetype is specified (not None), that value is used. Otherwise, content_type is used. If neither is given, the DEFAULT_CONTENT_TYPE setting is used.

However, I don't find it elucidating enough. Why we use 2 different naming for (almost the same) thing? Is "Content-Type" just a name used in browser requests, and with very little use outside it?

What's the main difference between the each one, and when is right to call something mimetype as opposed to content-type ? Am I being pitty and grammar nazi?

like image 581
Frangossauro Avatar asked Aug 10 '10 18:08

Frangossauro


People also ask

What is the meaning of MIME type?

A MIME type (now properly called "media type", but also sometimes "content type") is a string sent along with a file indicating the type of the file (describing the content format, for example, a sound file might be labeled audio/ogg , or an image file image/png ).

What is MIME type of a file?

A media type (also known as a Multipurpose Internet Mail Extensions or MIME type) indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

What is the difference between MIME type and media type?

(Internet) Media Type is the proper technical term. Content-Type is the name of the HTTP header field used to specify the media type. MIME Type is the former name for Media Type.

What is MIME type in Java?

A Multipurpose Internet Mail Extension (MIME) type, as defined in RFC 2045 and 2046.


1 Answers

Why we use 2 different naming for (almost the same) thing? Is "Content-Type" just a name used in browser requests, and with very little use outside it?

What's the main difference between the each one, and when is right to call something mimetype as opposed to content-type ? Am i being pitty and grammar nazi?

The reason isn't only backward compatibility, and I'm afraid the usually excellent Django documentation is a bit hand-wavy about it. MIME (it's really worth reading at least the Wikipedia entry) has its origin in extending internet mail, and specifically SMTP. From there, the MIME and MIME-inspired extension design has found its way into a lot of other protocols (such as HTTP here), and is still being used when new kinds of metadata or data need to be transmitted in an existing protocol. There are dozens of RFCs that discuss MIME used for a plethora of purposes.

Specifically, Content-Type: is one among several MIME headers. "Mimetype" does indeed sound obsolete, but a reference to MIME itself isn't. Call that part backward-compatibility, if you will.

[BTW, this is purely a terminology problem which has nothing whatsoever to do with grammar. Filing every usage question under "grammar" is a pet peeve of mine. Grrrr.]

like image 125
chryss Avatar answered Sep 30 '22 20:09

chryss