我正在尝试使用wkwebview从私有窗口下载文件,很遗憾无法下载文件。这是我得到的回应。
-[DownloadHandler saveDirectoryPathForResponse:][L:124]response <NSHTTPURLResponse: 0x600000434c20> { URL: https://osxDev.slack.com/?redir=%2Ffiles-pri%2FT0B5PPLCX-FF7NT0NNA%2Fdownload%2Fchalte_chalte_-_pagalworld.org } { Status Code: 200, Headers {
"Cache-Control" = (
"private, no-cache, no-store, must-revalidate"
);
"Content-Encoding" = (
gzip
);
"Content-Length" = (
19772
);
"Content-Type" = (
"text/html; charset=utf-8"
);
Date = (
"Wed, 23 Jan 2019 11:08:19 GMT"
);
Expires = (
"Mon, 26 Jul 1997 05:00:00 GMT"
);
Pragma = (
"no-cache"
);
Server = (
Apache
);
"Set-Cookie" = (
"d-s=1548241699; path=/; domain=.slack.com; secure; httponly",
"x=eo7res6xk440uh3keb6sggrzh.1548239853; expires=Wed, 23-Jan-2019 11:23:19 GMT; Max-Age=900; path=/; domain=.slack.com"
);
"Strict-Transport-Security" = (
"max-age=31536000; includeSubDomains; preload"
);
Vary = (
"Accept-Encoding"
);
Via = (
"1.1 5c49044a9bbc82066ce04ae597e1a6a7.cloudfront.net (CloudFront)"
);
"referrer-policy" = (
"no-referrer"
);
"x-amz-cf-id" = (
"jnczFrzoTMCmf-vZHd3M7jgYfKQEl0AEltH7fl74jZE144tGU2MvCw=="
);
"x-cache" = (
"Miss from cloudfront"
);
"x-frame-options" = (
SAMEORIGIN
);
"x-robots-tag" = (
"noindex,nofollow"
);
"x-via" = (
"haproxy-www-gd85"
);
"x-xss-protection" = (
0
);
} }
但是当我尝试使用非私有版本时,我可以下载并且响应为
-[DownloadHandler saveDirectoryPathForResponse:][L:124]response <NSHTTPURLResponse: 0x6040006244c0> { URL: https://files.slack.com/files-pri/T0B5PPLCX-FF7NT0NNA/download/chalte_chalte_-_pagalworld.org } { Status Code: 200, Headers {
"Accept-Ranges" = (
bytes
);
"Cache-Control" = (
"max-age=31536000, public"
);
Connection = (
"keep-alive"
);
"Content-Disposition" = (
"attachment; filename=\"Chalte Chalte - Pagalworld.org\"; filename*=UTF-8''Chalte%20Chalte%20-%20Pagalworld.org"
);
"Content-Length" = (
3763833
);
"Content-Type" = (
"audio/mpeg"
);
Date = (
"Wed, 23 Jan 2019 11:04:42 GMT"
);
Etag = (
"\"0c3a5aebdf8ab1acab4e098ccb77bc9a\""
);
Via = (
"1.1 b72519ee5ed84e4e3db077b5b7e93d38.cloudfront.net (CloudFront)"
);
"X-Amz-Cf-Id" = (
"aQ6auC2yu5RwLeYuEFyE3TT7tes36MTo5uGnTQ3vxXfGaZ2nAzxNJQ=="
);
"X-Backend" = (
"imgproxy-prod-pdx-lk25"
);
"X-Cache" = (
"Miss from cloudfront"
);
"X-Content-Type-Options" = (
nosniff
);
"X-Robots-Tag" = (
noindex
);
"X-Slack-Meta" = (
S3TA
);
} }
正如您在私人回复中看到的那样,它与非私人回复不同,并且缺少内容处置,您还可以看到响应URL有所不同。因此即使WKWebview处于私有模式下也要下载文件,该怎么做。
有什么建议吗?