edwinRNDR
07/16/2021, 12:04 PMclass KtorGraphQLRequestParser(
private val mapper: ObjectMapper
) : GraphQLRequestParser<ApplicationRequest> {
@Suppress("BlockingMethodInNonBlockingContext")
override suspend fun parseRequest(request: ApplicationRequest): GraphQLServerRequest = try {
val rawRequest = request.call.receiveText()
val encoded = rawRequest.toByteArray(Charsets.ISO_8859_1)
val decoded = String(encoded, Charsets.UTF_8)
mapper.readValue(decoded, GraphQLServerRequest::class.java)
} catch (e: IOException) {
throw IOException("Unable to parse GraphQL payload.")
}
}
Shane Myrick
07/16/2021, 3:04 PMJSON does NOT allow use of ISO-8859-1 as per specification; only UTF-8, UTF-16 and UTF-32 are supported
edwinRNDR
07/16/2021, 3:53 PMShane Myrick
07/16/2021, 4:05 PMedwinRNDR
07/16/2021, 4:09 PMShane Myrick
07/16/2021, 5:38 PM