diff --git a/src/jvmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/extension/UserRequestConversionExtension.kt b/src/jvmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/extension/UserRequestConversionExtension.kt index b08a8cd8..e8d40db3 100644 --- a/src/jvmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/extension/UserRequestConversionExtension.kt +++ b/src/jvmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/extension/UserRequestConversionExtension.kt @@ -29,6 +29,7 @@ import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType.Companion.toMediaType import okhttp3.Request import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder +import org.apache.hc.core5.http.ContentType import org.apache.hc.core5.http.message.BasicNameValuePair import org.apache.hc.core5.http.nio.AsyncRequestProducer import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers @@ -215,7 +216,13 @@ fun HttpRequest.toApacheHttpRequest(): Pair { *(entity.trailers?.get()?.toTypedArray() ?: emptyArray()) ) } - is StringBody -> AsyncEntityProducers.create(body.value, Charsets.UTF_8) + + is StringBody -> AsyncEntityProducers.create( + /* content = */ body.value, + /* contentType = */ contentType.headerValue?.let { ContentType.create(it, Charsets.UTF_8) } + ?: ContentType.DEFAULT_BINARY.withCharset(Charsets.UTF_8) + ) + null -> null else -> throw UnsupportedOperationException() }