Stop using internal variable from okhttp3 (#17458)

This commit is contained in:
Noor Dawod
2023-12-22 12:07:08 +01:00
committed by GitHub
parent 5eab3cef19
commit a67e07e132
24 changed files with 71 additions and 23 deletions

View File

@@ -15,7 +15,6 @@ import okhttp3.MultipartBody
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import okhttp3.internal.EMPTY_REQUEST
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
@@ -29,6 +28,8 @@ import java.time.OffsetTime
import java.util.Locale
import com.squareup.moshi.adapter
val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
companion object {
protected const val ContentType = "Content-Type"
@@ -219,6 +220,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
@Suppress("UNNECESSARY_SAFE_CALL")
return when {
response.isRedirect -> Redirection(
response.code,