RFR: 8297609: Add application/wasm MIME type for wasm file extension
Jaikiran Pai
jpai at openjdk.org
Fri Nov 25 13:20:54 UTC 2022
On Tue, 22 Nov 2022 14:54:37 GMT, Michal Karm Babacek <duke at openjdk.org> wrote:
>> This PR adds a missing MIME: application/wasm and unifies the file format on tabs, as that seemed to be the winning side of the tabs/spaces war in this file.
>>
>> # How to reproduce
>>
>> You will need to compile a `.c` file to a `.wasm` binary. Use [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) for that or download the prebuilt files from this post, [out.zip](https://github.com/openjdk/jdk/files/10066496/out.zip), if you choose to trust me with your browser...
>>
>> ## Sources
>>
>> `main.c`:
>>
>> #include <stdio.h>
>>
>> int main() {
>> printf("Hello browser debug console...\n");
>> }
>>
>>
>> `Server.java`:
>>
>> import com.sun.net.httpserver.HttpServer;
>> import com.sun.net.httpserver.SimpleFileServer;
>>
>> import java.net.InetAddress;
>> import java.net.InetSocketAddress;
>> import java.nio.file.Path;
>>
>> import static java.lang.System.exit;
>> import static java.lang.System.out;
>>
>> public class Server {
>> public static void main(String... args) {
>> if (args.length != 2) {
>> out.println("Usage: java Server <port> <web dir path>");
>> exit(1);
>> }
>> final int port = Integer.parseInt(args[0]);
>> final InetSocketAddress ADDR = new InetSocketAddress(InetAddress.getLoopbackAddress(), port);
>> final Path root = Path.of(args[1]).toAbsolutePath();
>> final HttpServer server = SimpleFileServer.createFileServer(ADDR, root, SimpleFileServer.OutputLevel.VERBOSE);
>> out.printf("Starting serving files from %s dir: http://%s:%d\n", root, ADDR.getAddress().getHostAddress(), port);
>> server.start();
>> }
>> }
>>
>> ## Build
>>
>> $ mkdir out
>> $ emcc main.c -s WASM=1 -o out/main.html
>> $ ls out/
>> main.html main.js main.wasm
>>
>> You can have these files here, built by me: [out.zip](https://github.com/openjdk/jdk/files/10066496/out.zip)
>>
>> ## Execution
>>
>> $ java --version
>> openjdk 19.0.1 2022-10-18
>> $ javac Server.java
>> $ java Server 8888 ./out/
>> Starting serving files from /tmp/hello_wasm/./out dir: http://127.0.0.1:8888
>>
>>
>> When I open my Firefox 106.0.5 (64-bit), I can see that the Java server offers the `.wasm` file with a suboptimal `application/octet-stream` MIME:
>>
>> 
>>
>> When I switch to the JDK patched with this patch and run the server again:
>>
>> $ java Server 8888 ./out/
>> Starting serving files from /tmp/hello_wasm/./out dir: http://127.0.0.1:8888
>>
>> I can see that the `.wasm` file is properly served to Firefox as `application/wasm`:
>>
>> 
>>
>> Thank you for your time.
>>
>> Cheers
>> K.
>
> @jerboaa Do you think I can go ahead and open PRs for 11u and 17u or the process is to wait for what happens with this one?
Hello @Karm, to officially initiate a review of this change, the review process (backed by bots) requires a JBS issue to be created and linked against this PR. I have created https://bugs.openjdk.org/browse/JDK-8297609 to track this.
Next, you will have to update the title of this PR to `8297609: Add application/wasm MIME type for wasm file extension` to link this PR against that issue. That will then initiate the necessary review process.
-------------
PR: https://git.openjdk.org/jdk/pull/11284
More information about the net-dev
mailing list