diff --git a/kgraphql-ktor/src/main/kotlin/com/apurebase/kgraphql/KtorFeature.kt b/kgraphql-ktor/src/main/kotlin/com/apurebase/kgraphql/KtorFeature.kt index b554be4f..5b1098e9 100644 --- a/kgraphql-ktor/src/main/kotlin/com/apurebase/kgraphql/KtorFeature.kt +++ b/kgraphql-ktor/src/main/kotlin/com/apurebase/kgraphql/KtorFeature.kt @@ -72,7 +72,7 @@ class GraphQL(val schema: Schema) { val routing: Route.() -> Unit = { route(config.endpoint) { post { - val bodyAsText = call.receiveTextWithCorrectEncoding() + val bodyAsText = call.receiveText() val request = decodeFromString(GraphqlRequest.serializer(), bodyAsText) val ctx = context { config.contextSetup?.invoke(this, call) @@ -107,17 +107,6 @@ class GraphQL(val schema: Schema) { return GraphQL(schema) } - private suspend fun ApplicationCall.receiveTextWithCorrectEncoding(): String { - fun ContentType.defaultCharset(): Charset = when (this) { - ContentType.Application.Json -> Charsets.UTF_8 - else -> Charsets.ISO_8859_1 - } - - val contentType = request.contentType() - val suitableCharset = contentType.charset() ?: contentType.defaultCharset() - return receiveStream().bufferedReader(charset = suitableCharset).readText() - } - private fun GraphQLError.serialize(): String = buildJsonObject { put("errors", buildJsonArray { addJsonObject {