Compare commits
No commits in common. "18143913b864e6f9ff46234c0b585efb38eded3d" and "274c59f979b4b9610870afa2fe4a3353170f583b" have entirely different histories.
18143913b8
...
274c59f979
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
|
@ -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,12 +39,14 @@ object CachingHttpClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUncached(uri: URI): InputStream {
|
fun getUncached(uri: URI): InputStream {
|
||||||
return CLIENT.send(
|
HttpClient.newHttpClient().use {
|
||||||
HttpRequest.newBuilder().uri(uri).header(
|
return it.send(
|
||||||
"User-Agent",
|
HttpRequest.newBuilder().uri(uri).header(
|
||||||
"FrogMC Phytotelma/" + CachingHttpClient.javaClass.`package`.implementationVersion
|
"User-Agent",
|
||||||
).build(), BodyHandlers.ofInputStream()
|
"FrogMC Phytotelma/" + CachingHttpClient.javaClass.`package`.implementationVersion
|
||||||
).body()
|
).build(), BodyHandlers.ofInputStream()
|
||||||
|
).body()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCacheFile(uri: URI): Path {
|
private fun getCacheFile(uri: URI): Path {
|
||||||
|
|
Loading…
Reference in a new issue