How does your browser know that if you have clicked on a link with a PDF file, that an in-built PDF viewer should be opened? How is your email software able to show images embedded within an email? How is it able to show attachments seperately from the body of the email? The answer is due to a standard called MIME or Multipurpose Internet Mail Extensions.
Before MIME was introduced, the Internet was a repository of English alphabet text-only content. Since it was used by scientists and mathematicians, the only things that were exchanged were thesis documents and formulae, for which texts were enough. Images were sent seperately. Web browsers, email clients and usenet clients assumed that any content that they accessed on the Internet was English language text. They could not show any other type of content, nor was there a way to know if any other type of content was sent. Everything would be shown as if it was text. So if you were to serve an image from a web server to a browser or an image through email (if it were hypothetically possible that time), then the browser or the recipient’s email software would show the contents of the image as random, gibberish text.
Concept of HTTP headers
Something that hasn’t changed either before or after MIME is that every piece of content on the Internet is sent from one machine to another along with ‘book-keeping labels’ called HTTP headers, similar to the way that postal service, courier companies and airport baggage check-in systems attach several labels to your package, baggage and cargo. The HTTP headers have information such as the time when the data is sent, how big the data is and which server software is sending the data. Here is how the headers look when Tech 101’s home page is sent to your browser.
Cache-Control: no-cache, must-revalidate, max-age=0
Content-Type: text/html; charset=UTF-8
Date: Tue, 14 Nov 2017 01:56:59 GMT
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Keep-Alive: timeout=5, max=100
Link: <http://www.tech101.in/wp-json/>; rel="https://api.w.org/"
Link: <http://www.tech101.in/>; rel=shortlink
Server: Apache/2.4.12 (Ubuntu)
They look geeky, but they mean a lot to your web browser and your web browser adjusts its behaviour accordingly. E.g. your browser knows that the content is a web page, that it is 10 KB long. It knows that the page should not be cached, because the expiry date is in the past (1984).
Introduction of MIME
In the early ’90s, it was suggested that browsers and email clients be able to handle multiple types of content such as images, animations and sounds. Even if the browser or client were not able to show the content, they could at least instruct an appropriate application in the computer to open that content.
The HTTP headers that were sent with each content came in handy. The scientists who created the web experimented with another header called ‘Content-Type’. This header was to be sent by the server along with other headers. By checking this header, the client software such as a browser or an email client would know what type of content was sent and how it should be shown.
E.g. if the server sends a header which reads “Content-Type: text/html”, then the data being sent is an HTML page. If it were “image/jpeg”, then a JPEG image is being sent. “video/mp4” accompanies an MP4 video.
An email with multiple attachments is a special case. There are two layers of headers that are sent. The first one is a master header for the entire email. Here the content type sent is “multipart/mixed”. This tells the email client that this email has multiple types of content. After the master header, each piece of content has its own content type header. The email body that probably says “Please find attached….” is text/plain. The attached powerpoint presentation is application/vnd.ms-powerpoint. The PDF file is tagged with application/pdf.
Regulation and IANA
Unregulated, there would be no standard on the format of the header and how each content should be represented. E.g. imagine the confusion if one server were to tag an image as “jpeg”, whereas another says “image/jpg” and another says “photo/jpg”. How would the browser be able to know which content type headers represent a JPEG image? On the same note, how would a browser know to distinguish between “text/pdf” and “document/pdf”?
To solve these problems, an standards committee was formed to standardise the header that should be sent with each type of content. Any data that fails to comply with the header formats mentioned in the standard will not be recognised by a browser or an email client. The header format was regularised to be in the following form,
Content-Type: <category>/<specific format>
So, a JPEG image will be image/jpeg, whereas a GIF animation will be image/gif. An MP4 video is tagged with video/mp4. However, there are some standards which do not exist officially, but almost every browser seems to accept an updated de-facto convention. E.g. officially MP3 files should be tagged audio/mpeg, but browsers will forgive you for tagging your favourite song as audio/mp3 or audio/mpeg3. This may not be the case with your favourite email client, so it is better to stick to the standard while sending files from a server.
Proprietary vendor-specific file types are classified as application/vnd.<vendor>-<file type>. E.g. Microsoft Word files are application/vnd.ms-word. Adobe’s PDF file format used to be application/vnd.adobe-pdf, but now since PDF has been released as an open standard, it has become application/pdf.
The IANA (Internet Assigned Numbers Authority) maintains a list of official MIME types here. This list is updated frequently.
MIME types while uploading
In the early ’90s, it was possible for browsers to only view content stored on a server, but not for browsers themselves to upload content. The only data browsers sent to servers was when a user filled up a form on a web page. But that changed in the late ’90s when browsers got the capability to upload images to photo sites like Flickr. Now, you can upload your own videos on Youtube and songs on Soundcloud. As a result, it became necessary to adopt MIME for browsers to send data to a server.
MIME has broken Internet out of its monotonous world of English text-only data and made it the rich world that it is today. Multi-lingual, expressive and vibrant with images, videos, sounds, charts and even 3-D movies. The Internet is still growing and we have no idea what the limits are. But MIME was the little solution that paved the way.