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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 71 additions and 23 deletions

View File

@ -35,9 +35,6 @@ import okhttp3.Response
{{#jvm-okhttp3}}
import okhttp3.internal.Util.EMPTY_REQUEST
{{/jvm-okhttp3}}
{{#jvm-okhttp4}}
import okhttp3.internal.EMPTY_REQUEST
{{/jvm-okhttp4}}
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
@ -77,6 +74,10 @@ import com.fasterxml.jackson.core.type.TypeReference
import com.squareup.moshi.adapter
{{/moshi}}
{{#jvm-okhttp4}}
{{#nonPublicApi}}internal {{/nonPublicApi}} val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
{{/jvm-okhttp4}}
{{#nonPublicApi}}internal {{/nonPublicApi}}open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
{{#nonPublicApi}}internal {{/nonPublicApi}}companion object {
protected const val ContentType = "Content-Type"
@ -411,6 +412,7 @@ import com.squareup.moshi.adapter
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{{#jvm-okhttp3}}(){{/jvm-okhttp3}},

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"
@ -200,6 +201,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,

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"
@ -200,6 +201,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,

View File

@ -26,6 +26,7 @@ import java.time.OffsetTime
import java.util.Locale
import com.squareup.moshi.adapter
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
companion object {
protected const val ContentType = "Content-Type"
@ -198,6 +199,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(),

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"
@ -200,6 +201,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,

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"
@ -200,6 +201,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,

View File

@ -26,6 +26,7 @@ import java.time.OffsetTime
import java.util.Locale
import com.squareup.moshi.adapter
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
companion object {
protected const val ContentType = "Content-Type"
@ -198,6 +199,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(),

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"
@ -200,6 +201,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,

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"
@ -200,6 +201,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,

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.google.gson.reflect.TypeToken
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"
@ -218,6 +219,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,

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.fasterxml.jackson.core.type.TypeReference
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"
@ -218,6 +219,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,

View File

@ -16,7 +16,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
@ -31,6 +30,8 @@ import java.util.Locale
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
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"
@ -224,6 +225,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,

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
@ -32,6 +31,8 @@ import kotlin.coroutines.resumeWithException
import kotlinx.coroutines.suspendCancellableCoroutine
import com.google.gson.reflect.TypeToken
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"
@ -232,6 +233,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,

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,

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,

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,

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"
@ -200,6 +201,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,

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
internal val EMPTY_REQUEST: RequestBody = ByteArray(0).toRequestBody()
internal open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
internal companion object {
protected const val ContentType = "Content-Type"
@ -219,6 +220,7 @@ internal open class ApiClient(val baseUrl: String, val client: OkHttpClient = de
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,

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,

View File

@ -26,6 +26,7 @@ import java.time.OffsetTime
import java.util.Locale
import com.squareup.moshi.adapter
open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClient) {
companion object {
protected const val ContentType = "Content-Type"
@ -217,6 +218,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(),

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,

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 org.threeten.bp.OffsetDateTime
import org.threeten.bp.OffsetTime
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,

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
@ -30,6 +29,8 @@ import java.util.Locale
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
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"
@ -200,6 +201,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,

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,