FileDownloader icon indicating copy to clipboard operation
FileDownloader copied to clipboard

下载有些资源失败,http 412错误

Open zhouxiongjie opened this issue 5 years ago • 7 comments

Connection failed with request[{If-Match=[W/"5dea0200-bd41"], Range=[bytes=0-], User-Agent=[FileDownloader/1.7.7]}] response[{null=[HTTP/1.1 412 Precondition Failed], Connection=[keep-alive], Content-Length=[195], Content-Type=[text/html; charset=utf-8], Date=[Fri, 06 Dec 2019 08:53:35 GMT], Server=[openresty/1.13.6.1], X-Android-Received-Millis=[1575622415051], X-Android-Response-Source=[NETWORK 412], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1575622415014]}] http-state[412] on task[-1974179381--1], which is changed after verify connection, so please try again. 这是输出错误

zhouxiongjie avatar Dec 06 '19 10:12 zhouxiongjie

可能因为是服务对对弱值 Etag 支持有问题,参照 #1066 ,将 etag 改为强值试试。

rantianhua avatar Dec 07 '19 01:12 rantianhua

error: Connection failed with request[{If-Match=["81405-5a231e6c9d912-gzip"], Range=[bytes=0-], User-Agent=[FileDownloader/1.7.4]}] response[{null=[HTTP/1.1 412 Precondition Failed], Accept-Ranges=[bytes], Connection=[Upgrade, Keep-Alive], Content-Length=[0], Content-Type=[application/vnd.openxmlformats-officedocument.presentationml.presentation], Date=[Wed, 08 Apr 2020 03:11:13 GMT], ETag=["81405-5a231e6c9d912"], Keep-Alive=[timeout=60, max=1000], Last-Modified=[Wed, 01 Apr 2020 03:01:32 GMT], Server=[Apache], Upgrade=[h2], X-Android-Received-Millis=[1586315470213], X-Android-Response-Source=[NETWORK 412], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1586315470177]}] http-state[412] on task[262543029--1], which is changed after verify connection, so please try again. 出现同样问题 但看着不是弱Etag

Doraemon123 avatar Apr 08 '20 03:04 Doraemon123

@rantianhua getting this error while downloading concurrent files.

request headers: {Range=[bytes=0-0], User-Agent=[FileDownloader/1.7.7]} response headers: {null=[HTTP/1.1 403 Forbidden], Alt-Svc=[h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"], Content-Length=[1103], Content-Type=[text/html; charset=UTF-8], Date=[Tue, 30 Jun 2020 15:10:23 GMT], X-Android-Received-Millis=[1593529823253], X-Android-Response-Source=[NETWORK 403], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1593529817185]}

kayesn786 avatar Jul 02 '20 15:07 kayesn786

Connection failed with request[{If-Match=["5e75b72e-3cb6"], Range=[bytes=0-], User-Agent=[FileDownloader/1.7.5]}] response[{null=[HTTP/1.1 412 Precondition Failed], Access-Control-Allow-Methods=[GET,POST,OPTIONS,HEAD], Access-Control-Allow-Origin=[*], Access-Control-Expose-Headers=[Authorization,Origin,X-Requested-With,Content-Type,Accept], Connection=[keep-alive], Content-Length=[0], Content-Type=[text/html], Date=[Mon, 13 Jul 2020 14:23:47 GMT], Location=[xxxxx], Server=[nginx], X-Android-Received-Millis=[1594650229263], X-Android-Response-Source=[NETWORK 412], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1594650229247], X-Via-Ucdn=[MISS by x.x.x.x, MISS by x.x.x.x]}] http-state[412] on task[-903433104--1], which is changed after verify connection, so please try again

yxwzaxns avatar Jul 13 '20 14:07 yxwzaxns

Connection failed with request[{If-Match=[W/"5f0ffe38-55769c8"], Range=[bytes=0-], User-Agent=[FileDownloader/0.0.1]}] response[{null=[HTTP/1.1 412 Precondition Failed], Connection=[keep-alive], Content-Length=[173], Content-Type=[text/html], Date=[Thu, 16 Jul 2020 09:24:13 GMT], Server=[nginx/1.16.1], X-Android-Received-Millis=[1594891453354], X-Android-Response-Source=[NETWORK 412], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1594891453116]}] http-state[412] on task[-1296041228--1], which is changed after verify connection, so please try again.

hayukleung avatar Jul 16 '20 09:07 hayukleung

有同样问题

"Connection failed with request[{Connection=[close], If-Match=[9eca7026d6a3253cb2e2d1c77f25c1cf], p=[L3TkhLK5TBFxc4Drgd5uL4nziXFugwUweahpR9V4bT3wf7W0iPF6NZVmkZ9BMUO7QYm8Tf1wbF9miN0=], Range=[bytes=88914262-89566183], s=[c5655481855a1fcd4605cfa9129dd924], User-Agent=[FileDownloader/1.0.1], v=[b11fe760be080b353c584e5144c9147a]}] response[{null=[HTTP/1.1 412 Precondition Failed], Age=[597609], CF-Cache-Status=[HIT], CF-RAY=[6029af72aad21ec2-AMS], cf-request-id=[070debfba800001ec2d8b7b000000001], Connection=[close], Content-Type=[text/html], Date=[Wed, 16 Dec 2020 16:12:20 GMT], NEL=[{"report_to":"cf-nel","max_age":604800}], Report-To=[{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=AyxXi5BNqas7sQT9NJjEA27pZIx0bM%2BFlsTNSePAORHBVIiJPIFX44oGedcmL236i%2FvdeDKg8lwgLLtLo1%2B1MwcscOx3RBw%2F8cXJK1P0XQtvoQi9sjBq68Himw0dQf9TNA%3D%3D"}],"group":"cf-nel","max_age":604800}], Server=[cloudflare], Set-Cookie=[__cfduid=d2f7a4524a32b7723fc484f90732ccdea1608135140; expires=Fri, 15-Jan-21

qyzhaojinxi avatar Dec 18 '20 06:12 qyzhaojinxi

对我来说, 第一个版本服务端没有对文件下载进行鉴权限制,可以正常下载,第二个版本,服务端开始改造增加鉴权,对已经调用过一次的下载链接进行失效处理,我这边就会遇到下面这样的异常,

ava.net.SocketException: Connection failed with request[{Range=[bytes=4073926-8147851], User-Agent=[FileDownloader/1.7.7]}] response[{null=[HTTP/1.1 403 Forbidden], Access-Control-Allow-Methods=[GET], Access-Control-Allow-Origin=[*], Connection=[keep-alive], Content-Length=[238], Content-Type=[text/html], Date=[Mon, 29 Jan 2024 02:42:16 GMT], EagleId=[907b1f2217064961368347077e], Server=[Tengine], Timing-Allow-Origin=[*], Via=[cache14.cn1306[,0]], X-Android-Received-Millis=[1706496136376], X-Android-Response-Source=[NETWORK 403], X-Android-Selected-Protocol=[http/1.1], X-Android-Sent-Millis=[1706496136196]}] http-state[403] on task[-891346639-1], which is changed after verify connection, so please try again.   

最终发现是因为 下载库默认开启断点续传。 image

Range 是一个请求首部,告知服务器返回文件的哪一部分。在一个 Range 首部中,可以一次性请求多个部分,服务器会以 multipart 文件的形式将其返回。如果服务器返回的是范围响应,需要使用 206 Partial Content 状态码。假如所请求的范围不合法,那么服务器会返回 416 Range Not Satisfiable 状态码,表示客户端错误。服务器允许忽略 Range 首部,从而返回整个文件,状态码用 200

所以我这边的情况是,服务端做修改适配客户端的断点续传,客户端不需要修改。

Seachal avatar Jan 31 '24 08:01 Seachal