Bug 412410 - Static resources do not have Content-Type (MIME type) set and are always treated as binary
Summary: Static resources do not have Content-Type (MIME type) set and are always trea...
Status: NEW
Alias: None
Product: Virgo
Classification: RT
Component: snaps (show other bugs)
Version: 3.6.1.RELEASE   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-07-05 10:08 EDT by Mark Peters CLA
Modified: 2017-02-03 16:55 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Peters CLA 2013-07-05 10:08:51 EDT
The Snaps style sample (org.eclipse.virgo.snaps.sample.blue) is a good example.  When running the sample, the resource 

http://localhost:8080/animal-menu-bar/styles/main.css

is sent down with no Content-Type header.  Chrome gives a warning in its console:

"Resource interpreted as Stylesheet but transferred with MIME type text/plain"

(text/plain must be the fallback, in reality there was no MIME type specified).

Along these same lines, StaticResourceServlet does not send text files using the Servlet's Writer, but always transfers the files as binary.  Combined with the fact that no character encoding is specified in the headers, the client has to guess at the encoding.

Tomcat has sane mime-mapping defaults for its static resource servlet.  It knows to map "js" to "application/javascript", "css" to "text/css", etc.  But this isn't just a question of defaults.  Adding explicit mime-mapping elements to the Snap's web.xml has no effect; these configurations are completely ignored by Snaps.