Stop using internal OkHttp APIs (#11172)
This commit is contained in:
parent
84714f887f
commit
5db3e03d15
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'MangaDex'
|
extName = 'MangaDex'
|
||||||
pkgNameSuffix = 'all.mangadex'
|
pkgNameSuffix = 'all.mangadex'
|
||||||
extClass = '.MangaDexFactory'
|
extClass = '.MangaDexFactory'
|
||||||
extVersionCode = 157
|
extVersionCode = 158
|
||||||
isNsfw = true
|
isNsfw = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import okhttp3.MediaType.Companion.toMediaType
|
|||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.closeQuietly
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,16 +60,14 @@ class MdAtHomeReportInterceptor(
|
|||||||
|
|
||||||
val jsonString = json.encodeToString(result)
|
val jsonString = json.encodeToString(result)
|
||||||
|
|
||||||
val postResult = client.newCall(
|
try {
|
||||||
|
client.newCall(
|
||||||
POST(
|
POST(
|
||||||
MDConstants.atHomePostUrl,
|
MDConstants.atHomePostUrl,
|
||||||
headers,
|
headers,
|
||||||
jsonString.toRequestBody("application/json".toMediaType())
|
jsonString.toRequestBody("application/json".toMediaType())
|
||||||
)
|
)
|
||||||
)
|
).execute().close()
|
||||||
try {
|
|
||||||
val body = postResult.execute()
|
|
||||||
body.closeQuietly()
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.e("MangaDex", "Error trying to POST report to MD@Home: ${e.message}")
|
Log.e("MangaDex", "Error trying to POST report to MD@Home: ${e.message}")
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ ext {
|
|||||||
extName = 'Dmzj'
|
extName = 'Dmzj'
|
||||||
pkgNameSuffix = 'zh.dmzj'
|
pkgNameSuffix = 'zh.dmzj'
|
||||||
extClass = '.Dmzj'
|
extClass = '.Dmzj'
|
||||||
extVersionCode = 27
|
extVersionCode = 28
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -4,8 +4,6 @@ import android.util.Log
|
|||||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import okhttp3.internal.closeQuietly
|
|
||||||
import java.lang.Exception
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An OkHttp interceptor that will switch to a failover address and retry when an HTTP GET request
|
* An OkHttp interceptor that will switch to a failover address and retry when an HTTP GET request
|
||||||
@ -45,7 +43,11 @@ class HttpGetFailoverInterceptor : Interceptor {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Log.d(LOG_TAG, "[HttpGetFailoverInterceptor] failed with exception, next: $retry", e)
|
Log.d(LOG_TAG, "[HttpGetFailoverInterceptor] failed with exception, next: $retry", e)
|
||||||
}
|
}
|
||||||
response?.closeQuietly()
|
try {
|
||||||
|
response?.close()
|
||||||
|
} catch (_: Exception) {
|
||||||
|
// Ignore exceptions
|
||||||
|
}
|
||||||
request = request.newBuilder().url(retry).build()
|
request = request.newBuilder().url(retry).build()
|
||||||
}
|
}
|
||||||
return chain.proceed(request)
|
return chain.proceed(request)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user