feat: add option to support non-ascii headers in kotlin client (#20331)

This commit is contained in:
Kirill Romanov
2024-12-15 11:46:42 +03:00
committed by GitHub
parent 07d19baf89
commit 4e5a828c12
79 changed files with 5029 additions and 23 deletions

View File

@@ -10,6 +10,7 @@ import okhttp3.ResponseBody
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Request
import okhttp3.Headers
import okhttp3.Headers.Builder
import okhttp3.Headers.Companion.toHeaders
import okhttp3.MultipartBody
import okhttp3.Call
@@ -291,7 +292,11 @@ open class ApiClient(val baseUrl: String, val client: Call.Factory = defaultClie
RequestMethod.POST -> Request.Builder().url(url).post(requestBody(requestConfig.body, contentType))
RequestMethod.OPTIONS -> Request.Builder().url(url).method("OPTIONS", null)
}.apply {
headers.forEach { header -> addHeader(header.key, header.value) }
val headersBuilder = Headers.Builder()
headers.forEach { header ->
headersBuilder.add(header.key, header.value)
}
this.headers(headersBuilder.build())
}.build()
val response = client.newCall(request).execute()