fuel
fuel copied to clipboard
Response callback is called on cancel
Using fuel-android 2.2.1 with kotlin to download files.
My code is as follows
request = Fuel.download(uri).fileDestination { response, url ->
File(filesDir,fileName)
}.progress { readBytes, totalBytes ->
//handle progerss
}.interrupt { request ->
deleteFile(fileName)
}.response { req, res, result ->
//handle result
}
when I call result.cancel()
the response callback is called after interrupt one with the following error :
thread interrupted
com.github.kittinunf.fuel.core.FuelError$Companion.wrap(FuelError.kt:86)
com.github.kittinunf.fuel.toolbox.HttpClient.executeRequest(HttpClient.kt:39)
Caused by: java.io.InterruptedIOException: thread interrupted
com.android.okhttp.okio.Timeout.throwIfReached(Timeout.java:145)
com.android.okhttp.okio.Okio$1.write(Okio.java:73)
com.android.okhttp.okio.AsyncTimeout$1.write(AsyncTimeout.java:155)
com.android.okhttp.okio.RealBufferedSink.flush(RealBufferedSink.java:221)
com.android.okhttp.internal.http.Http1xStream.finishRequest(Http1xStream.java:161)
com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:735)
com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:609)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:471)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaders(HttpURLConnectionImpl.java:163)
com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaderFields(HttpURLConnectionImpl.java:223)
com.github.kittinunf.fuel.toolbox.HttpClient.retrieveResponse(HttpClient.kt:144)
com.github.kittinunf.fuel.toolbox.HttpClient.doRequest(HttpClient.kt:79)
com.github.kittinunf.fuel.toolbox.HttpClient.executeRequest(HttpClient.kt:36)
com.github.kittinunf.fuel.core.requests.RequestTask.executeRequest(RequestTask.kt:23)
com.github.kittinunf.fuel.core.requests.RequestTask.call(RequestTask.kt:44)
com.github.kittinunf.fuel.core.requests.RequestTask.call(RequestTask.kt:14)
com.github.kittinunf.fuel.core.requests.RequestTaskCallbacks.call(RequestTaskCallbacks.kt:28)
com.github.kittinunf.fuel.core.requests.RequestTaskCallbacks.call(RequestTaskCallbacks.kt:20)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
java.lang.Thread.run(Thread.java:764)