0

I need Quarkus to serve my wasm file with Content-Type header application/wasm instead of application/octet-stream. I explicitly use the quarkus-undertow extension.

First I tried to use the undertow-handlers.conf to set the content type like this:

path-suffix('.wasm') -> set("o{Content-Type}", "application/wasm")

For other headers this works without problem, but the Content-Type seems to be overwritten by a following handler.

After this I tried to add a web.xml under src/main/resources/META-INF with a mime mapping for wasm files like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         id="WebApp_ID" version="3.1">

    <mime-mapping>
        <extension>wasm</extension>
        <mime-type>application/wasm</mime-type>
    </mime-mapping>
</web-app>

This approach doesn't seem to have any effect on the Content-Type.

What is the correct way to overwrite mime type mappings for static files in Quarkus? Why does the web.xml configuration not work?


Update

The web.xml approach from above works since Quarkus 1.1.1.Final.

Michael Kleimann
  • 502
  • 2
  • 10

1 Answers1

1

Did you add the quarkus-undertow extension explicitly? Because by default, it's not present and things are served by Vert.x so you need to add a Vert.x handler instead.

Guillaume Smet
  • 9,921
  • 22
  • 29
  • Yes I added the quarkus-undertow extension with Quarkus update 0.24.0 I think. I am not sure why I need it, probably because I use oidc? – Michael Kleimann Dec 29 '19 at 18:29
  • From what I can see, the mime mappings added to the web.xml are purely and simply ignored by the Quarkus Undertow extension. Can you open an issue in our tracker? That's certainly something we need to take a look at. Thanks. – Guillaume Smet Dec 29 '19 at 21:18
  • Sure, I opened a bug on github: https://github.com/quarkusio/quarkus/issues/6399 – Michael Kleimann Jan 04 '20 at 16:05