Node JS Proper Content-Type for responses


Is there a reason that I should not be sending my content-type as binary for everything? I am a bit naive about proper http but it seems to work for everything. What are some of the pitfalls I will run into working this way?

Problem courtesy of: Prospero


If you send a stylesheet as Content Type binary, IE9 won’t render it. It refuses to render any stylesheet that isn’t text/css. That’s probably enough to keep people from not visiting your site with IE9.

Not to mention the other benefits like the browser handling specific content types differently based on user preferences.

Edit Here, you can use this, it will make it easier to determine the content type. The module will have two methods. getExt and getContentType. If you pass the extension to getContentType it will return the Content-Type for that file. I’m not the one that compiled all the content types, unfortunately I forgot where I found it…

Solution courtesy of: Robert

View additional discussion.