Serve .jar files with the correct MIME type

Signed-off-by: Graham <gpe@openrs2.org>
pull/132/head
Graham 3 years ago
parent 89f7a192f9
commit 86a84c6986
  1. 3
      game/src/main/kotlin/org/openrs2/game/net/http/Http.kt
  2. 16
      game/src/main/kotlin/org/openrs2/game/net/http/HttpChannelHandler.kt

@ -18,7 +18,10 @@ import org.openrs2.buffer.use
public object Http {
public const val MAX_CONTENT_LENGTH: Int = 65536
public const val APPLICATION_JAVA_ARCHIVE: String = "application/java-archive"
public const val TEXT_X_CROSS_DOMAIN_POLICY: String = "text/x-cross-domain-policy"
private const val BANNER = "OpenRS2"
private fun isKeepAlive(request: HttpRequest, version: HttpVersion): Boolean {

@ -34,7 +34,21 @@ public class HttpChannelHandler @Inject constructor(
return
}
Http.writeResponse(ctx, msg, file, HttpHeaderValues.APPLICATION_OCTET_STREAM)
Http.writeResponse(ctx, msg, file, getContentType(uri))
}
}
private fun getContentType(uri: String): CharSequence {
/*
* It doesn't make sense to return a MIME type for some of the files:
*
* - The .pack200 files are missing two bytes in the header.
* - The .lib and .pack files are probably compressed with DEFLATE in
* nowrap mode.
*/
return when {
uri.endsWith(".jar") -> Http.APPLICATION_JAVA_ARCHIVE
else -> HttpHeaderValues.APPLICATION_OCTET_STREAM
}
}

Loading…
Cancel
Save