Update Okhttp, Jackson and retrofit
This commit is contained in:
parent
dee4675715
commit
e153565086
|
@ -17,8 +17,8 @@ fun Response<out ResponseBody>.toStreamResponse(): StreamResponse {
|
||||||
val contentType = responseBody?.contentType()
|
val contentType = responseBody?.contentType()
|
||||||
if (
|
if (
|
||||||
contentType != null &&
|
contentType != null &&
|
||||||
contentType.type().equals("application", true) &&
|
contentType.type.equals("application", true) &&
|
||||||
contentType.subtype().equals("json", true)
|
contentType.subtype.equals("json", true)
|
||||||
) {
|
) {
|
||||||
val error = SubsonicAPIClient.jacksonMapper.readValue<SubsonicResponse>(
|
val error = SubsonicAPIClient.jacksonMapper.readValue<SubsonicResponse>(
|
||||||
responseBody.byteStream()
|
responseBody.byteStream()
|
||||||
|
@ -40,7 +40,7 @@ fun Response<out ResponseBody>.toStreamResponse(): StreamResponse {
|
||||||
* It creates Exceptions from the results returned by the Subsonic API
|
* It creates Exceptions from the results returned by the Subsonic API
|
||||||
*/
|
*/
|
||||||
@Suppress("ThrowsCount")
|
@Suppress("ThrowsCount")
|
||||||
fun <T : SubsonicResponse> Response<out T>.throwOnFailure(): Response<out T> {
|
fun <T : SubsonicResponse> Response<T>.throwOnFailure(): Response<T> {
|
||||||
val response = this
|
val response = this
|
||||||
|
|
||||||
if (response.isSuccessful && response.body()!!.status === SubsonicResponse.Status.OK) {
|
if (response.isSuccessful && response.body()!!.status === SubsonicResponse.Status.OK) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ class SubsonicAPIClient(
|
||||||
.addInterceptor { chain ->
|
.addInterceptor { chain ->
|
||||||
// Adds default request params
|
// Adds default request params
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val newUrl = originalRequest.url().newBuilder()
|
val newUrl = originalRequest.url.newBuilder()
|
||||||
.addQueryParameter("u", config.username)
|
.addQueryParameter("u", config.username)
|
||||||
.addQueryParameter("c", config.clientID)
|
.addQueryParameter("c", config.clientID)
|
||||||
.addQueryParameter("f", "json")
|
.addQueryParameter("f", "json")
|
||||||
|
|
|
@ -18,7 +18,7 @@ class PasswordHexInterceptor(private val password: String) : Interceptor {
|
||||||
|
|
||||||
override fun intercept(chain: Chain): Response {
|
override fun intercept(chain: Chain): Response {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val updatedUrl = originalRequest.url().newBuilder()
|
val updatedUrl = originalRequest.url.newBuilder()
|
||||||
.addEncodedQueryParameter("p", passwordHex).build()
|
.addEncodedQueryParameter("p", passwordHex).build()
|
||||||
return chain.proceed(originalRequest.newBuilder().url(updatedUrl).build())
|
return chain.proceed(originalRequest.newBuilder().url(updatedUrl).build())
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class PasswordMD5Interceptor(private val password: String) : Interceptor {
|
||||||
override fun intercept(chain: Chain): Response {
|
override fun intercept(chain: Chain): Response {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val salt = getSalt()
|
val salt = getSalt()
|
||||||
val updatedUrl = originalRequest.url().newBuilder()
|
val updatedUrl = originalRequest.url.newBuilder()
|
||||||
.addQueryParameter("t", getPasswordMD5Hash(salt))
|
.addQueryParameter("t", getPasswordMD5Hash(salt))
|
||||||
.addQueryParameter("s", salt)
|
.addQueryParameter("s", salt)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -19,7 +19,7 @@ internal const val TIMEOUT_MILLIS_PER_OFFSET_BYTE = 0.02
|
||||||
internal class RangeHeaderInterceptor : Interceptor {
|
internal class RangeHeaderInterceptor : Interceptor {
|
||||||
override fun intercept(chain: Chain): Response {
|
override fun intercept(chain: Chain): Response {
|
||||||
val originalRequest = chain.request()
|
val originalRequest = chain.request()
|
||||||
val headers = originalRequest.headers()
|
val headers = originalRequest.headers
|
||||||
return if (headers.names().contains("Range")) {
|
return if (headers.names().contains("Range")) {
|
||||||
val offsetValue = headers["Range"] ?: "0"
|
val offsetValue = headers["Range"] ?: "0"
|
||||||
val offset = "bytes=$offsetValue-"
|
val offset = "bytes=$offsetValue-"
|
||||||
|
|
|
@ -18,7 +18,7 @@ internal class VersionInterceptor(
|
||||||
val newRequest = originalRequest.newBuilder()
|
val newRequest = originalRequest.newBuilder()
|
||||||
.url(
|
.url(
|
||||||
originalRequest
|
originalRequest
|
||||||
.url()
|
.url
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addQueryParameter("v", protocolVersion.restApiVersion)
|
.addQueryParameter("v", protocolVersion.restApiVersion)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -22,9 +22,9 @@ kotlin = "1.6.10"
|
||||||
kotlinxCoroutines = "1.6.0-native-mt"
|
kotlinxCoroutines = "1.6.0-native-mt"
|
||||||
viewModelKtx = "2.3.0"
|
viewModelKtx = "2.3.0"
|
||||||
|
|
||||||
retrofit = "2.6.4"
|
retrofit = "2.9.0"
|
||||||
jackson = "2.9.5"
|
jackson = "2.10.1"
|
||||||
okhttp = "3.12.13"
|
okhttp = "4.9.1"
|
||||||
koin = "3.0.2"
|
koin = "3.0.2"
|
||||||
picasso = "2.71828"
|
picasso = "2.71828"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue