Dariusz Kuc
09/22/2022, 12:47 AMContent-Length
header (default in v1.6) vs Transfer-Encoding: chunked
(default in v2.0)?Dariusz Kuc
09/22/2022, 12:48 AMHttpClient(engineFactory = Apache) {
install(HttpTimeout) {
connectTimeoutMillis = connectTimeout
requestTimeoutMillis = readTimeout
}
install(feature = JsonFeature)
}.use { client ->
runBlocking {
val introspectionResult = try {
<http://client.post|client.post><Map<String, Any?>> {
url(endpoint)
contentType(ContentType.Application.Json)
httpHeaders.forEach { (name, value) ->
header(name, value)
}
body = mapOf(
"query" to INTROSPECTION_QUERY,
"operationName" to "IntrospectionQuery"
)
}
} catch (e: Throwable) {
when (e) {
is ClientRequestException, is HttpRequestTimeoutException, is UnknownHostException -> throw e
else -> throw RuntimeException("Unable to run introspection query against the specified endpoint=$endpoint", e)
}
}
}
Dariusz Kuc
09/22/2022, 12:49 AMHttpClient(engineFactory = Apache) {
install(HttpTimeout) {
connectTimeoutMillis = connectTimeout
requestTimeoutMillis = readTimeout
}
install(ContentNegotiation) {
jackson()
}
}.use { client ->
runBlocking {
val introspectionResult = try {
<http://client.post|client.post> {
url(endpoint)
contentType(ContentType.Application.Json)
httpHeaders.forEach { (name, value) ->
header(name, value)
}
setBody(
mapOf(
"query" to INTROSPECTION_QUERY,
"operationName" to "IntrospectionQuery"
)
)
expectSuccess = true
}.body<Map<String, Any?>>()
} catch (e: Throwable) {
when (e) {
is ClientRequestException, is HttpRequestTimeoutException, is UnknownHostException -> throw e
else -> throw RuntimeException("Unable to run introspection query against the specified endpoint=$endpoint", e)
}
}
}
Rustam Siniukov
09/22/2022, 10:35 AMKotlinxSerializationConverter
2. create your own JacksonConverter
, that will return TextContent
instead of OutputStreamContent
. The converter itself is about 100 loc and you can copy most of it from existing one
3. create a ticket in YouTrack and wait when the Ktor team will address itDariusz Kuc
09/22/2022, 2:12 PMDariusz Kuc
09/22/2022, 4:00 PMRustam Siniukov
09/22/2022, 5:04 PMDariusz Kuc
09/22/2022, 5:13 PM