[FIX] Более правильное определение ContentType.

This commit is contained in:
Zaxar163 2020-01-09 15:35:33 +01:00
parent 9351cc1de5
commit 0dcd212d27
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B
2 changed files with 9 additions and 3 deletions

View file

@ -17,10 +17,16 @@ public String forPath(File p) {
try {
return Files.probeContentType(p.toPath());
} catch (Throwable e) {
return null;
return UNIVERSAL.forPath(p);
}
}
};
},
UNIVERSAL {
@Override
public String forPath(File p) {
return "application/octet-stream";
}
};
public abstract String forPath(File p);
}

View file

@ -34,7 +34,7 @@ public class FileServerHandler extends SimpleChannelInboundHandler<FullHttpReque
}
public static final int HTTP_CACHE_SECONDS = VerifyHelper.verifyInt(Integer.parseInt(System.getProperty("launcher.fileserver.cachesec", "60")), VerifyHelper.NOT_NEGATIVE, "HttpCache seconds should be positive");
private static final boolean OLD_ALGO = Boolean.parseBoolean(System.getProperty("launcher.fileserver.oldalgo", "true"));
private static final ContentType TYPE_PROBE = Arrays.stream(ContentType.values()).filter(e -> e.name().toLowerCase(Locale.US).equals(System.getProperty("launcher.fileserver.typeprobe", "nio"))).findFirst().orElse(ContentType.NONE);
private static final ContentType TYPE_PROBE = Arrays.stream(ContentType.values()).filter(e -> e.name().toLowerCase(Locale.US).equals(System.getProperty("launcher.fileserver.typeprobe", "nio"))).findFirst().orElse(ContentType.UNIVERSAL);
private final Path base;
private final boolean fullOut;
private final boolean showHiddenFiles;