Is it possible to cancel a long running HTTP reque...
# ktor
n
Is it possible to cancel a long running HTTP request without having a exception thrown?
e
Hi @napperley, you can try
withTimeoutOrNull
n
Is there is no way to manually to cancel a request without a timeout occurring?
With the
Job
I used a
isActive
property check along with a
cancel
function call, eg:
Copy code
if (refreshJob != null && refreshJob!!.isActive) {
    refreshJob?.cancel(CancellationException("Refresh cancelled by user"))
    refreshJob = null
    // ...
}
e
Yep. And you can get response job in client like this:
myHttpResponse.coroutineContext[Job]
👍 1
152 Views