Justin Moy
07/06/2021, 7:07 PMIllegalStateException
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)
}
}
this.HttpClientLogging {
level = Level.TRACE
}
Aleksei Tirman [JB]
07/07/2021, 9:44 AMIllegalStateException
?Justin Moy
07/07/2021, 3:02 PMcall.response.status(HttpStatusCode.Accepted)
call.respond(HttpStatusCode.Accepted)
and it fixed itAleksei Tirman [JB]
07/07/2021, 3:51 PMIllegalStateException
using Ktor 1.6.1e5l
07/12/2021, 9:43 AMcall.respond
explicitly
It was a bug that using of just call.response.status(HttpStatusCode.Accepted)
was allowed and it was reason of freezes in some cases.