WIldfly 8.1.0 'Content-Type' response header filter ignored by Undertow 1.1
pawel.predki Aug 22, 2014 6:36 PMWe are running Wildfly 8.1.0 and we wanted to set up a directory for static files to be served directly by Undertow. This is what how we set up our standalone.xml:
<subsystem xmlns="urn:jboss:domain:undertow:1.1">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<https-listener name="defaultssl" socket-binding="https" security-realm="SSLRealm"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<location name="/playlist" handler="playlist"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<filter-ref name="access-control-allow-origin-header"/>
<filter-ref name="content-mp4" predicate="path-suffix['.mp4']"/>
<filter-ref name="content-m3u8" predicate="path-suffix['.m3u8']"/>
<filter-ref name="content-jpg" predicate="path-suffix['.jpg'] or path-suffix['.jpeg']"/>
</host>
</server>
<servlet-container name="default" default-encoding="UTF-8">
<jsp-config/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
<file name="playlist" path="/home/wildfly/playlist" directory-listing="true"/>
</handlers>
<filters>
<response-header name="content-mp4" header-name="Content-Type" header-value="video/mp4"/>
<response-header name="content-m3u8" header-name="Content-Type" header-value="application/x-mpegurl"/>
<response-header name="content-jpg" header-name="Content-Type" header-value="image/jpeg"/>
<response-header name="server-header" header-name="Server" header-value="WildFly/8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
<response-header name="access-control-allow-origin-header" header-name="Access-Control-Allow-Origin" header-value="*"/>
</filters>
</subsystem>
Unfortunately, the content-x filters are ignored or overwritten and for all m3u8 and mp4 files we always get Content-Type=application/octet-stream. For the .jpg files the content type is correct.
The question is if it's at all possible to apply the Content-Type header filter to such requests or if there's any other way to force the correct content type for particular files? I tried looking into the Undertow extension code and I found the SharedWebMetaDataBuilder.java class which includes the mp4 MIME type but it is not applied to the requests we make (wildfly/SharedWebMetaDataBuilder.java at bfc41360196f5183a005101bf7ac2d7bfa1389c0 · wildfly/wildfly · GitHub).
Any help would be very appreciated.