diff --git a/game/src/main/kotlin/org/openrs2/game/net/http/Http.kt b/game/src/main/kotlin/org/openrs2/game/net/http/Http.kt index 13b9f4af0b..fea1bab7d6 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/http/Http.kt +++ b/game/src/main/kotlin/org/openrs2/game/net/http/Http.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 { diff --git a/game/src/main/kotlin/org/openrs2/game/net/http/HttpChannelHandler.kt b/game/src/main/kotlin/org/openrs2/game/net/http/HttpChannelHandler.kt index 7e04fe8653..7fbac7fa30 100644 --- a/game/src/main/kotlin/org/openrs2/game/net/http/HttpChannelHandler.kt +++ b/game/src/main/kotlin/org/openrs2/game/net/http/HttpChannelHandler.kt @@ -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 } }