Upgrade 2 cancel request

I read for a while about canceling a request in modification 2. As far as I read about canceling requests, onFailure () is called, and the request is removed from the queue if not sent. But what happens if the request is already sent (I know that we will receive the callback onFailure ()), but did the actual HTTP request cancel on the server?

To clarify, let's say I upload an image to a server. The request has been sent, and now the call is canceled, I know that I will receive the onFailure callback for Android, but will the image be uploaded to the server or will it be left on the server side?

This may be the main thing in network requests, but since this is my first meeting that does not know how canceling requests.

+4
source share
1 answer

Calling the cancelretrofit object Callwill close the connection socket if the connection is established.

This means that if you are in the middle of a file download and you call the method cancel(), then the connection will be closed immediately and the file download will fail.

But if you cancel the call after the file download is completed and the server sends a response message, the file will be downloaded.

+2
source

Source: https://habr.com/ru/post/1687288/


All Articles