hellman
01/29/2021, 3:25 PMexpectSuccess
to false
. But if I do that, I can’t get the deserialized body.
This means that when I get a valid response, like 302 Found
, I still get an exception.
How is this meant to be used?Rustam Siniukov
01/29/2021, 3:30 PMhellman
01/29/2021, 3:31 PMval thing = try {
<http://client.post|client.post><Thing>(url)
} catch (e: RedirectResponseException) { // 3xx response code
// can't get deserialized body here!
}
Rustam Siniukov
01/29/2021, 3:32 PMe.response.receive<YourDataClass>()
doesn’t work for you? what is the error?hellman
01/29/2021, 3:32 PMByteReadChannel
so I have to do the deserialization myselfRustam Siniukov
01/29/2021, 3:34 PMhellman
01/29/2021, 3:34 PMNoTransformationFoundException: No transformation found: class io.ktor.utils.io.ByteBufferChannel (Kotlin reflection is not available) -> class com.Thing (Kotlin reflection is not available)
Rustam Siniukov
01/29/2021, 3:36 PMContentType
header?hellman
01/29/2021, 3:36 PMRustam Siniukov
01/29/2021, 3:41 PMhellman
01/29/2021, 3:41 PMRustam Siniukov
01/29/2021, 3:42 PMhellman
01/29/2021, 3:42 PMRustam Siniukov
01/29/2021, 4:12 PMscope.receivePipeline.intercept(HttpReceivePipeline.After) { response ->
context.response = object : HttpResponse() {
override val call: HttpClientCall = response.call
override val status: HttpStatusCode = response.status
override val version: HttpProtocolVersion = response.version
override val requestTime: GMTDate = response.requestTime
override val responseTime: GMTDate = response.responseTime
override val content: ByteReadChannel = response.content
override val headers: Headers = Headers.build { appendAll(response.headers); append(/* you headers*/) }
override val coroutineContext: CoroutineContext = response.coroutineContext
}
proceedWith(context.response)
}
hellman
01/29/2021, 4:14 PMcontext.response
only has an internal setter. 😕Rustam Siniukov
01/29/2021, 5:41 PMhellman
01/29/2021, 5:47 PM