From ee9510d049c95876d916e92dc1986933626b424d Mon Sep 17 00:00:00 2001 From: Sunny Chung Date: Wed, 21 Feb 2024 23:57:35 +0800 Subject: [PATCH] fix wrong `content-type` header --- .../hellohttp/extension/UserRequestConversionExtension.kt | 4 ++++ 1 file changed, 4 insertions(+) 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 0e9740c8..0bc2506c 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 @@ -90,6 +90,10 @@ fun UserRequestTemplate.toHttpRequest( application = application, ) + if (req.headers.none { "content-type".equals(it.first, ignoreCase = true) } && req.contentType.headerValue != null) { + req = req.copy(headers = req.headers + ("Content-Type" to req.contentType.headerValue!!)) + } + if (application == ProtocolApplication.Graphql) { val graphqlBody = req.body as GraphqlBody val baseGraphqlBody = baseExample.body as GraphqlBody