hey, we're upgrading from ktor 1.4 to ktor 1.6 and are encountering an
IllegalStateException
when trying to use our ktor client to call a ktor server for our integration tests, anyone able to take a look?
This is the error message when
customPost()
is called:
Failed to parse request body: request body length should be specified, chunked transfer encoding should be used or keep-alive should be disabled (connection: close)
setup:
val httpClient = HttpClient(CIO) {
expectSuccess = false
}
suspend inline fun <reified TRequestData> customPost(
url: String,
requestCacheKey: String,
requestContent: TRequestData,
headers: Map<String, String>? = null,
contentType: ContentType = ContentType.Application.Json
) {
<http://httpClient.post|httpClient.post><HttpResponse>(url) {
var contentAstString = requestCacheManager.getOrCreateRawString(requestCacheKey) { requestContent } // returns a string
headers?.forEach { headerKey, value ->
header(headerKey, value)
}
body = TextContent(contentAstString, contentType)
}
}