aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/lorenz/mod/utils/APIUtil.kt
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-14 12:06:07 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-14 12:06:07 +0200
commitd1a99b2a9a9859c922002771c3d8229fab2ecb8d (patch)
treedbbe5b208e6871378a10868d1206d1d78beeb950 /src/main/java/at/lorenz/mod/utils/APIUtil.kt
parentf20b096222ebbffd7decec2fecf1416002644865 (diff)
downloadSkyHanni-d1a99b2a9a9859c922002771c3d8229fab2ecb8d.tar.gz
SkyHanni-d1a99b2a9a9859c922002771c3d8229fab2ecb8d.tar.bz2
SkyHanni-d1a99b2a9a9859c922002771c3d8229fab2ecb8d.zip
renamed mod to SkyHanni
Diffstat (limited to 'src/main/java/at/lorenz/mod/utils/APIUtil.kt')
-rw-r--r--src/main/java/at/lorenz/mod/utils/APIUtil.kt48
1 files changed, 0 insertions, 48 deletions
diff --git a/src/main/java/at/lorenz/mod/utils/APIUtil.kt b/src/main/java/at/lorenz/mod/utils/APIUtil.kt
deleted file mode 100644
index 7e0193f50..000000000
--- a/src/main/java/at/lorenz/mod/utils/APIUtil.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package at.lorenz.mod.utils
-
-import com.google.gson.JsonObject
-import com.google.gson.JsonParser
-import org.apache.http.client.config.RequestConfig
-import org.apache.http.client.methods.HttpGet
-import org.apache.http.impl.client.HttpClientBuilder
-import org.apache.http.impl.client.HttpClients
-import org.apache.http.message.BasicHeader
-import org.apache.http.util.EntityUtils
-
-
-object APIUtil {
- private val parser = JsonParser()
-
- val builder: HttpClientBuilder =
- HttpClients.custom().setUserAgent("LorenzMod")
- .setDefaultHeaders(
- mutableListOf(
- BasicHeader("Pragma", "no-cache"),
- BasicHeader("Cache-Control", "no-cache")
- )
- )
- .setDefaultRequestConfig(
- RequestConfig.custom()
- .build()
- )
- .useSystemProperties()
-
- fun getJSONResponse(urlString: String): JsonObject {
- val client = builder.build()
- try {
- client.execute(HttpGet(urlString)).use { response ->
- val entity = response.entity
- if (entity != null) {
- val retSrc = EntityUtils.toString(entity)
- return parser.parse(retSrc) as JsonObject
- }
- }
- } catch (ex: Throwable) {
- ex.printStackTrace()
- LorenzUtils.error("Lorenz Mod ran into an ${ex::class.simpleName ?: "error"} whilst fetching a resource. See logs for more details.")
- } finally {
- client.close()
- }
- return JsonObject()
- }
-} \ No newline at end of file