https://github.com/spring-projects/spring-boot/blob/cc1807608e6569c1ceb49e558c99f622d6d788d4/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java#L206
Please prepend:
mappings.add("wasm", "application/wasm");
To the indicated line. Currently I'm handling recognition of the wasm payload as such:
@Component
public class ServletCustomizer implements EmbeddedServletContainerCustomizer
{
@Override
public void customize(final ConfigurableEmbeddedServletContainer container)
{
final MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
mappings.add("wasm", "application/wasm");
container.setMimeMappings(mappings);
}
}
Thank you for your time!
See (https://webassembly.org/docs/web/) for further details on the type.
This compilation can be performed in the background and in a streaming manner. If the Response is not CORS-same-origin, does not represent an ok status, or does not match the
application/wasmMIME type, the returned promise will be rejected with a TypeError;
This was previously held up by IANA status which has now been resolved.
References:
https://github.com/WebAssembly/spec/issues/573#issuecomment-824715263
https://www.iana.org/assignments/media-types/application/wasm
https://github.com/spring-projects/spring-boot/issues/17254
Comment From: bclozel
Looking at https://github.com/spring-projects/spring-boot/issues/17254#issuecomment-503619255, it sounds like we were not waiting for IANA official registration but rather its adoption by Servlet containers. It looks like this MIME type got added in Tomcat with https://github.com/apache/tomcat/commit/54898ee4c0974fc3280abcb753e54d76d2149d2c .
Maybe we should consider it then?
Comment From: wilkinsona
Tomcat added it in 9.0.37 so I think we should add it. Like Phil, I thought we had some tests that checked our mappings were in sync with Tomcat's but we haven't had a test failure so I'm not sure what's going on there.
Comment From: wilkinsona
I think this may explain it:
Both Jetty and Undertow have default mime mappings that Boot's mime mappings are then added to, whereas Tomcat just uses Boot's mime mappings.
So if Jetty or Undertow add new mappings that aren't in Boot's mappings, we'll get a test failure. If Tomcat adds a new mapping, it'll get overwritten by Boot's mappings and we won't notice it.
I think we should try to improve the tests (it's AbstractServletWebServerFactoryTests.mimeMappingsAreCorrectlyConfigured() that covers this at the moment) and add any mappings that are missing, including application/wasm.
Comment From: wilkinsona
In early 2020, Tomcat aligned the mappings that it uses for embedded instances with those that were configured in its conf/web.xml. As a result of that alignment, we're now missing 837(!) mappings. We've only got 176 mappings at the moment so aligning will result in a significant increase (almost 5x) in the default mappings.
Comment From: StefanBratanov
Hi, is it possible to assign this to me? I can give it a go. 🙂
Comment From: StefanBratanov
I gave it a try and raised a PR https://github.com/spring-projects/spring-boot/pull/30897 . Hope it's not a problem.
I basically added the missing Tomcat default mappings to MimeMappings.java class and modified the test to make it more robust for the future.
I only added the missing mappings and didn't touch the ones who already existed. Though, I noticed some differences in the Tomcat mappings to the already existing Boot mappings. Few differences for example are:
- Boot:
mappings.add("ms", "application/x-wais-source");Tomcat:ms=text/troff - Boot:
mappings.add("otf", "application/x-font-opentype");Tomcat:otf=font/otf
Not sure if this is a concern.
Comment From: wilkinsona
Thanks, @StefanBratanov, but as indicated by the comments above, I am already working on this.
Comment From: StefanBratanov
Thanks, @StefanBratanov, but as indicated by the comments above, I am already working on this.
Sure, no worries! Thought it's unassigned.
Comment From: wilkinsona
We discussed this today and decided to use this issue to only add a mapping for application/wasm. We've opened https://github.com/spring-projects/spring-boot/issues/31171 to track broader alignment.