[downloader:http] treat 416 without downloaded data as error

Downloading https://pbs.twimg.com/media/EB2cGUYX4AI2Vuu.jpg:orig (NSFW)
sometimes returns a 416 status code, even though no 'Range' header was
sent and no data was downloaded prior.
This code usually means a file has already been downloaded completely
and the download method indicates success, but in this case it causes
an exception down the pipeline since no file was created.
This commit is contained in:
Mike Fährmann
2019-08-19 23:46:58 +02:00
parent 2495b99347
commit ebabc5caf1

View File

@@ -103,7 +103,7 @@ class HttpDownloader(DownloaderBase):
elif code == 206: # Partial Content
offset = filesize
size = response.headers["Content-Range"].rpartition("/")[2]
elif code == 416: # Requested Range Not Satisfiable
elif code == 416 and filesize: # Requested Range Not Satisfiable
break
else:
msg = "{}: {} for url: {}".format(code, response.reason, url)