Compare commits

..

No commits in common. "18143913b864e6f9ff46234c0b585efb38eded3d" and "274c59f979b4b9610870afa2fe4a3353170f583b" have entirely different histories.

2 changed files with 9 additions and 10 deletions

View file

@ -46,8 +46,7 @@ gradlePlugin {
tasks.jar { tasks.jar {
manifest { manifest {
attributes( attributes("Implementation-Version" to version,
"Implementation-Version" to version,
"Implementation-Date" to Date(), "Implementation-Date" to Date(),
"Implementation-Name" to project.name "Implementation-Name" to project.name
) )

View file

@ -17,8 +17,6 @@ import kotlin.io.path.notExists
object CachingHttpClient { object CachingHttpClient {
private val CLIENT = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NORMAL).build()
fun downloadTo(uri: URI, path: Path, allowOverwrite: Boolean) { fun downloadTo(uri: URI, path: Path, allowOverwrite: Boolean) {
if (allowOverwrite || path.notExists()) { if (allowOverwrite || path.notExists()) {
path.createParentDirectories() path.createParentDirectories()
@ -41,13 +39,15 @@ object CachingHttpClient {
} }
fun getUncached(uri: URI): InputStream { fun getUncached(uri: URI): InputStream {
return CLIENT.send( HttpClient.newHttpClient().use {
return it.send(
HttpRequest.newBuilder().uri(uri).header( HttpRequest.newBuilder().uri(uri).header(
"User-Agent", "User-Agent",
"FrogMC Phytotelma/" + CachingHttpClient.javaClass.`package`.implementationVersion "FrogMC Phytotelma/" + CachingHttpClient.javaClass.`package`.implementationVersion
).build(), BodyHandlers.ofInputStream() ).build(), BodyHandlers.ofInputStream()
).body() ).body()
} }
}
private fun getCacheFile(uri: URI): Path { private fun getCacheFile(uri: URI): Path {
val path = PhytotelmaPlugin.globalCacheDir.resolve("httpCache") val path = PhytotelmaPlugin.globalCacheDir.resolve("httpCache")