Clean up http server content types

This commit is contained in:
Melledy
2022-09-01 12:53:20 -07:00
Unverified
parent a1c31d1779
commit fee34c515d
8 changed files with 47 additions and 756 deletions
@@ -3,6 +3,7 @@ package emu.grasscutter.server.http.objects;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.utils.FileUtils;
import emu.grasscutter.utils.HttpUtils;
import io.javalin.http.ContentType;
import io.javalin.http.Context;
import io.javalin.http.Handler;
@@ -23,9 +24,8 @@ public class WebStaticVersionResponse implements Handler {
private static void getPageResources(String path, Context ctx) {
try (InputStream filestream = FileUtils.readResourceAsStream(path)) {
HttpUtils.MediaType fromExtension = HttpUtils.MediaType.getByExtension(path.substring(path.lastIndexOf(".") + 1));
ctx.contentType((fromExtension != null) ? fromExtension.getMIME() : "application/octet-stream");
ContentType fromExtension = ContentType.getContentTypeByExtension(path.substring(path.lastIndexOf(".") + 1));
ctx.contentType(fromExtension != null ? fromExtension : ContentType.APPLICATION_OCTET_STREAM);
ctx.result(filestream.readAllBytes());
} catch (Exception e) {
if (DISPATCH_INFO.logRequests == Grasscutter.ServerDebugMode.MISSING) {