Content Type Issue in Wildfly 10

I have a web application on Wildfly 10 and in the web application directory I put the zip file that I want to download when the user clicks on the hyperlink. In the user interface, I

Excerpt

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

It creates the 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 loads the exe file, but in Wildfly it displays all the unnecessary characters on the screen, since its content type is text / html

I tried to set the mime type to standalone-full.xml but it did not work.

  <mime-mappings> <mime-mapping name="css" value="text/css"/> <mime-mapping name="exe" value="application/octet-stream"/> </mime-mappings> 
+5
source share
1 answer

The documentation at undertow.io shows how to manually set the MIME type for each response, for example. exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/octet-stream"); , while a file with MIME type mappings can be called web.xml (make sure that the file you want is referenced). In addition, I can imagine that the servlet filter cannot be configured as it should - and sends a request where they should not end (found fooobar.com/tags/servlet-filters / ... ). while this answer even shows how to add MIME types at runtime: fooobar.com/questions/1271976 / ... (the usual one should nevertheless serve application/octet-stream when writing a binary stream to the output - which implies that it may also be the result of an illegal input stream).

0
source

Source: https://habr.com/ru/post/1271974/


All Articles