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) {
|
||||
walletRepository.getRemoteClients().first().forEach {
|
||||
val currentProxy = it.httpClient.proxy()
|
||||
if (currentProxy != newProxy) {
|
||||
val builder = it.httpClient.newBuilder()
|
||||
it.httpClient = builder.proxy(newProxy).build()
|
||||
walletRepository.getRemoteClients().first().forEach { client ->
|
||||
val current = client.httpClient.proxy
|
||||
if (current != newProxy) {
|
||||
val builder = client.httpClient.newBuilder()
|
||||
client.httpClient = builder.proxy(newProxy).build()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ android {
|
||||
}
|
||||
|
||||
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.appcompat:appcompat:1.3.0'
|
||||
|
@ -7,6 +7,8 @@ import im.molly.monero.loadbalancer.Rule
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import okhttp3.*
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@ -69,15 +71,15 @@ class RemoteNodeClient private constructor(
|
||||
runCatching {
|
||||
requestWithRetry(method, path, header, body)
|
||||
}.onSuccess { response ->
|
||||
val statusCode = response.code()
|
||||
val responseBody = response.body()
|
||||
val status = response.code
|
||||
val responseBody = response.body
|
||||
if (responseBody == null) {
|
||||
callback?.onResponse(statusCode, null, null)
|
||||
callback?.onResponse(status, null, null)
|
||||
} else {
|
||||
val contentType = responseBody.contentType()?.toString()
|
||||
val pipe = ParcelFileDescriptor.createPipe()
|
||||
|
||||
callback?.onResponse(statusCode, contentType, pipe[0])
|
||||
callback?.onResponse(status, contentType, pipe[0])
|
||||
|
||||
responseBody.use {
|
||||
pipe[1].use { writeSide ->
|
||||
@ -163,16 +165,14 @@ class RemoteNodeClient private constructor(
|
||||
body: ByteArray?,
|
||||
): Response {
|
||||
val headers = parseHttpHeader(header)
|
||||
val contentType = headers.get("Content-Type")?.let { value ->
|
||||
MediaType.get(value)
|
||||
}
|
||||
val contentType = headers["Content-Type"]?.toMediaType()
|
||||
// TODO: Log unsupported headers
|
||||
val request = with(Request.Builder()) {
|
||||
when {
|
||||
method.equals("GET", ignoreCase = true) -> {}
|
||||
method.equals("POST", ignoreCase = true) -> {
|
||||
val content = body ?: ByteArray(0)
|
||||
post(RequestBody.create(contentType, content))
|
||||
post(content.toRequestBody(contentType))
|
||||
}
|
||||
else -> throw IllegalArgumentException("Unsupported method")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user