I've recently been working on a little project to serve static files. I want to be able to serve different types of files like:
html, jpg, png, pdf, doc...
All files seem to render correctly in different browsers without assigning a MIME type.
For example, if I serve an image and declare a MIME type I would write this in my node.js code:
response.writeHead(200, {'Content-Type': 'image/jpg'});
response.end(data);
Ignoring the MIME type will render the exact same results in different browsers:
response.writeHead(200);
response.end(data);
It is my understanding that if no MIME type is declared in the header, the browser will do its best to figure it out.
According to the HTTP specifications, the 'Content-Type' header is not required.
As with all multipart MIME types, each part has an optional "Content-Type", which defaults to text/plain.
Should I declare a MIME type for each response? Why?