Fix me not knowing that "" is not a number - also rc7 tiem
This commit is contained in:
parent
907e90803d
commit
a6e7f10d6e
|
@ -7,7 +7,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "com.mangadex"
|
group = "com.mangadex"
|
||||||
version = "1.0.0-rc6"
|
version = "1.0.0-rc7"
|
||||||
mainClassName = "mdnet.base.MangaDexClient"
|
mainClassName = "mdnet.base.MangaDexClient"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -71,17 +71,27 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting
|
||||||
statistics.get().requestsServed.incrementAndGet()
|
statistics.get().requestsServed.incrementAndGet()
|
||||||
|
|
||||||
// Netty doesn't do Content-Length or Content-Type, so we have the pleasure of doing that ourselves
|
// Netty doesn't do Content-Length or Content-Type, so we have the pleasure of doing that ourselves
|
||||||
fun respondWithImage(input: InputStream, length: String, type: String, lastModified: String): Response =
|
fun respondWithImage(input: InputStream, length: String?, type: String, lastModified: String?): Response =
|
||||||
Response(Status.OK).header("Content-Length", length)
|
Response(Status.OK)
|
||||||
.header("Content-Type", type)
|
.header("Content-Type", type)
|
||||||
.header("X-Content-Type-Options", "nosniff")
|
.header("X-Content-Type-Options", "nosniff")
|
||||||
.header("Last-Modified", lastModified)
|
|
||||||
.header(
|
.header(
|
||||||
"Cache-Control",
|
"Cache-Control",
|
||||||
listOf("public", MaxAgeTtl(Constants.MAX_AGE_CACHE).toHeaderValue()).joinToString(", ")
|
listOf("public", MaxAgeTtl(Constants.MAX_AGE_CACHE).toHeaderValue()).joinToString(", ")
|
||||||
)
|
)
|
||||||
.header("Timing-Allow-Origin", "https://mangadex.org")
|
.header("Timing-Allow-Origin", "https://mangadex.org")
|
||||||
.body(input, length.toLong())
|
.also {
|
||||||
|
if(length != null) {
|
||||||
|
it.body(input, length.toLong())
|
||||||
|
it.header("Content-Length", length)
|
||||||
|
} else {
|
||||||
|
it.body(input)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lastModified != null) {
|
||||||
|
it.header("Last-Modified", lastModified)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val snapshot = cache.get(cacheId)
|
val snapshot = cache.get(cacheId)
|
||||||
if (snapshot != null) {
|
if (snapshot != null) {
|
||||||
|
@ -169,7 +179,7 @@ fun getServer(cache: DiskLruCache, serverSettings: ServerSettings, clientSetting
|
||||||
LOGGER.trace("Request for ${request.uri} is being served")
|
LOGGER.trace("Request for ${request.uri} is being served")
|
||||||
}
|
}
|
||||||
|
|
||||||
respondWithImage(mdResponse.body.stream, contentLength ?: "", contentType, lastModified ?: "")
|
respondWithImage(mdResponse.body.stream, contentLength, contentType, lastModified)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue