{"action":"created","issue":{"url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/issues/40","labels_url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/issues/40/labels{/name}","comments_url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/issues/40/comments","events_url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/issues/40/events","html_url":"https://github.com/thibaultCha/TCBlobDownload/pull/40","id":46754311,"number":40,"title":"Handle 416 status code by deleting the local file and retrying","user":{"login":"Benjamin-Dobell","id":482276,"avatar_url":"https://avatars.githubusercontent.com/u/482276?v=3","gravatar_id":"","url":"https://api.github.com/users/Benjamin-Dobell","html_url":"https://github.com/Benjamin-Dobell","followers_url":"https://api.github.com/users/Benjamin-Dobell/followers","following_url":"https://api.github.com/users/Benjamin-Dobell/following{/other_user}","gists_url":"https://api.github.com/users/Benjamin-Dobell/gists{/gist_id}","starred_url":"https://api.github.com/users/Benjamin-Dobell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Benjamin-Dobell/subscriptions","organizations_url":"https://api.github.com/users/Benjamin-Dobell/orgs","repos_url":"https://api.github.com/users/Benjamin-Dobell/repos","events_url":"https://api.github.com/users/Benjamin-Dobell/events{/privacy}","received_events_url":"https://api.github.com/users/Benjamin-Dobell/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2014-10-24T16:03:11Z","updated_at":"2015-05-08T00:16:59Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/pulls/40","html_url":"https://github.com/thibaultCha/TCBlobDownload/pull/40","diff_url":"https://github.com/thibaultCha/TCBlobDownload/pull/40.diff","patch_url":"https://github.com/thibaultCha/TCBlobDownload/pull/40.patch"},"body":"A server returns 416 if the range we've provided to it is invalid. Whilst the local partially downloaded file exists, any attempt to retry using the same range is guaranteed to fail (unless the file is replaced on the server).\r\n\r\nThe only way to resolve the issue is to send a valid range header (unknown at this point) or not send one at all.\r\n\r\nThis patch, in response to a 416 status code, seamlessly deletes the local partially downloaded file and retries the file download. Because the local file has been deleted the retry attempt will not include a range header and hence 416 won't be returned again i.e. no infinite retrying.\r\n\r\nIf for some odd reason the local file can't be deleted then we gracefully fallback to the previous behaviour of calling the error callback with the 416 status code error."},"comment":{"url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/issues/comments/100053251","html_url":"https://github.com/thibaultCha/TCBlobDownload/pull/40#issuecomment-100053251","issue_url":"https://api.github.com/repos/thibaultCha/TCBlobDownload/issues/40","id":100053251,"user":{"login":"thibaultCha","id":1125431,"avatar_url":"https://avatars.githubusercontent.com/u/1125431?v=3","gravatar_id":"","url":"https://api.github.com/users/thibaultCha","html_url":"https://github.com/thibaultCha","followers_url":"https://api.github.com/users/thibaultCha/followers","following_url":"https://api.github.com/users/thibaultCha/following{/other_user}","gists_url":"https://api.github.com/users/thibaultCha/gists{/gist_id}","starred_url":"https://api.github.com/users/thibaultCha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thibaultCha/subscriptions","organizations_url":"https://api.github.com/users/thibaultCha/orgs","repos_url":"https://api.github.com/users/thibaultCha/repos","events_url":"https://api.github.com/users/thibaultCha/events{/privacy}","received_events_url":"https://api.github.com/users/thibaultCha/received_events","type":"User","site_admin":false},"created_at":"2015-05-08T00:16:59Z","updated_at":"2015-05-08T00:16:59Z","body":"Hi, sorry for the big delay! Could you please rebase? I would be willing to merge this. Thank you :)"}}