Inconsistent behavior when cancelling request with range header (ios vs. android)
See original GitHub issuereact-native-cli: 2.0.1 react-native: 0.51.0 RNFetchBlob: 0.10.8
So when downloading something like so:
task = RNFetchBlob.config({
path: dest,
overwrite: false,
IOSBackgroundTask: true,
indicator: true,
}).fetch('GET', url, {
Range: `bytes=${size}-`,
});
task.then(handleSuccess)
.catch(handleError)
and then calling task.cancel()
, I observe different behavior on iOS vs android.
iOS:
handleError(err)
gets called where err.message === 'cancelled'
. So this is nicely catcheable.
android:
handleSuccess(success)
is called, where success
has a HTTP code 206, which suggests that the range request was satisfied? It looks exactly like the response I get when the request finished successfully. Here is the content of respInfo
, and it is the same whether I cancel the task or not:
headers: [
Accept-Ranges: "bytes"
Content-Length: "20177379"
Content-Range: "bytes 0-20177378/20177379"
Content-Type: "audio/mp3"
Date: "Fri, 04 May 2018 08:39:03 GMT"
ETag: ""...""
Last-Modified: "Tue, 12 Dec 2017 13:36:08 GMT"
Server: "AmazonS3"
x-amz-id-2: "..."
x-amz-request-id: "..."
]
redirects: ["https://s3-eu-west-1.amazonaws.com/.../efaaa2177b5f494390896e70d5444837.mp3"]
respType: ""
rnfbEncode: "path"
state: "2"
status: 206
taskId: "jwy3rlqv5rkr1deb205f4p"
timeout: false
Any takes on why this happens?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
HTTP byte range protocol client behaviour on iPad/iPhone
iPad gets a chunk or two and then unilaterally decides to stop accepting bytes from the server and issues a separate GET request...
Read more >440904 - Extraneous 1 byte range requests issued prior to ...
1. Request any piece of content. 2. Forcibly cancel the connection after some content is received. 3. Request the content again with the...
Read more >react-native/CHANGELOG.md at main - GitHub
getAllResponseHeaders() now returns headers with names lowercased and sorted in ascending order, as per specification (b2415c4866 by @ascherkus) ...
Read more >AsyncTask - Android Developers
AsyncTask was intended to enable proper and easy use of the UI thread. ... It also has inconsistent behavior on different versions of...
Read more >Outlook for iOS and Android in Exchange Online: FAQ
The Outlook for iOS and Android app is designed to enable users in your ... Online PowerShell) and which appears in HTTP request...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Not really sure what @gigby is saying but the issue is on iOS
task.cancel()
throws a catchable error while Android it doesn’t throw an error and succeeds normally. There is PR up here => https://github.com/joltup/rn-fetch-blob/pull/363If that is the case, I believe it should be fixed