mirror of
https://github.com/mollyim/monero-wallet-sdk.git
synced 2024-10-01 03:45:36 -04:00
lib: update okhttp to 4.10.0
This commit is contained in:
parent
c468972738
commit
529184abaf
@ -82,11 +82,11 @@ class SettingsViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun onProxyChanged(newProxy: Proxy) {
|
private suspend fun onProxyChanged(newProxy: Proxy) {
|
||||||
walletRepository.getRemoteClients().first().forEach {
|
walletRepository.getRemoteClients().first().forEach { client ->
|
||||||
val currentProxy = it.httpClient.proxy()
|
val current = client.httpClient.proxy
|
||||||
if (currentProxy != newProxy) {
|
if (current != newProxy) {
|
||||||
val builder = it.httpClient.newBuilder()
|
val builder = client.httpClient.newBuilder()
|
||||||
it.httpClient = builder.proxy(newProxy).build()
|
client.httpClient = builder.proxy(newProxy).build()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api 'com.squareup.okhttp3:okhttp:3.12.13'
|
api 'com.squareup.okhttp3:okhttp:4.10.0'
|
||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.9.0'
|
implementation 'androidx.core:core-ktx:1.9.0'
|
||||||
// implementation 'androidx.appcompat:appcompat:1.3.0'
|
// implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||||
|
@ -7,6 +7,8 @@ import im.molly.monero.loadbalancer.Rule
|
|||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
@ -69,15 +71,15 @@ class RemoteNodeClient private constructor(
|
|||||||
runCatching {
|
runCatching {
|
||||||
requestWithRetry(method, path, header, body)
|
requestWithRetry(method, path, header, body)
|
||||||
}.onSuccess { response ->
|
}.onSuccess { response ->
|
||||||
val statusCode = response.code()
|
val status = response.code
|
||||||
val responseBody = response.body()
|
val responseBody = response.body
|
||||||
if (responseBody == null) {
|
if (responseBody == null) {
|
||||||
callback?.onResponse(statusCode, null, null)
|
callback?.onResponse(status, null, null)
|
||||||
} else {
|
} else {
|
||||||
val contentType = responseBody.contentType()?.toString()
|
val contentType = responseBody.contentType()?.toString()
|
||||||
val pipe = ParcelFileDescriptor.createPipe()
|
val pipe = ParcelFileDescriptor.createPipe()
|
||||||
|
|
||||||
callback?.onResponse(statusCode, contentType, pipe[0])
|
callback?.onResponse(status, contentType, pipe[0])
|
||||||
|
|
||||||
responseBody.use {
|
responseBody.use {
|
||||||
pipe[1].use { writeSide ->
|
pipe[1].use { writeSide ->
|
||||||
@ -163,16 +165,14 @@ class RemoteNodeClient private constructor(
|
|||||||
body: ByteArray?,
|
body: ByteArray?,
|
||||||
): Response {
|
): Response {
|
||||||
val headers = parseHttpHeader(header)
|
val headers = parseHttpHeader(header)
|
||||||
val contentType = headers.get("Content-Type")?.let { value ->
|
val contentType = headers["Content-Type"]?.toMediaType()
|
||||||
MediaType.get(value)
|
|
||||||
}
|
|
||||||
// TODO: Log unsupported headers
|
// TODO: Log unsupported headers
|
||||||
val request = with(Request.Builder()) {
|
val request = with(Request.Builder()) {
|
||||||
when {
|
when {
|
||||||
method.equals("GET", ignoreCase = true) -> {}
|
method.equals("GET", ignoreCase = true) -> {}
|
||||||
method.equals("POST", ignoreCase = true) -> {
|
method.equals("POST", ignoreCase = true) -> {
|
||||||
val content = body ?: ByteArray(0)
|
val content = body ?: ByteArray(0)
|
||||||
post(RequestBody.create(contentType, content))
|
post(content.toRequestBody(contentType))
|
||||||
}
|
}
|
||||||
else -> throw IllegalArgumentException("Unsupported method")
|
else -> throw IllegalArgumentException("Unsupported method")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user