Wasm文件由Quarkus提供了错误的Content-Type标头

问题描述 投票:0回答:1

我需要Quarkus使用Content-Type标头application/wasm而不是application/octet-stream来提供wasm文件。

首先,我尝试使用undertow-handlers.conf设置内容类型,如下所示:

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

对于其他标头,这没有问题,但是Content-Type似乎被后面的处理程序覆盖。

此后,我尝试在src/main/resources/META-INF下添加一个web.xml,该文件具有类似wasm文件的mime映射:

<?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>

此方法似乎对Content-Type没有任何影响。

为Quarkus中的静态文件覆盖mime类型映射的正确方法是什么?为什么web.xml配置不起作用?

mime-types web.xml webassembly undertow quarkus
1个回答
1
投票

您是否明确添加了quarkus-undertow扩展名?因为默认情况下,它不存在并且由Vert.x提供服务,所以您需要添加一个Vert.x处理程序。

© www.soinside.com 2019 - 2024. All rights reserved.