Content type issue in Wildfly 10

Viewed 1267

I have a web application on Wildfly 10 and in the web application directory i have placed a zip file that I want to be downloaded when user clicks on the hyperlink. On the UI I have

Snippet

<div class="tyDiv" onclick="window.open('request.getContextPath() + "/downloads/Installer.exe")%>','_self')">
</div>

It creates correct url like

"http://192.168.2.123:8080/comp/downloads/Installer.exe"


Content-Type:text/html;charset=UTF-8

This works in JBoss6 as expected . It downloads the exe file but in Wildfly it display all the junk characters on the screen as its content type is text/html

I tried setting mime type in standalone-full.xml but did not work.

 <mime-mappings>
    <mime-mapping name="css" value="text/css"/>
    <mime-mapping name="exe" value="application/octet-stream"/>
 </mime-mappings>
1 Answers

The documentation at undertow.io shows how to manually set the MIME type per response, eg. exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream"); while the file with the MIME type mappings might possibly be called web.xml (make sure the correct file is being referenced). Beside that, I could imagine that the servlet-filter may not be configured as it should - and it dispatches the request where they should not end up (have found https://stackoverflow.com/tags/servlet-filters/info). while this answer here even shows how to add MIME types at runtime: https://stackoverflow.com/a/38021097/549372 (ordinary is should nevertheless serve application/octet-stream while writing a binary stream to the output - which implies, that it also could be the result of a wrongful input stream).

Related