当我运行如下下载任务时:
let request = URLRequest(url:url)
request.httpMethod = "GET"
// blahblah
let dataTask = session.downloadTask(with: request) {localUrl, response, error in
// blahblah
}
// blahblah
dataTask?.resume()
我得到了403。 我需要自动处理csp:有人知道怎么做吗?
<NSHTTPURLResponse: 0x2826b1880> { URL: https://www.wired.com/story/how-to-easily-locate-the-accelerometer-in-an-iphone/ } { Status Code: 402, Headers {
"Accept-Ranges" = (
bytes,
bytes
);
"Cache-Control" = (
"no-cache"
);
"Content-Length" = (
150370
);
"Content-Type" = (
"text/html; charset=utf-8"
);
Date = (
"Sat, 15 Sep 2018 17:18:47 GMT"
);
"Strict-Transport-Security" = (
"max-age=31536000; preload"
);
Vary = (
"accept-payment, accept-encoding"
);
Via = (
"1.1 varnish"
);
"content-security-policy" = (
"default-src https: data: 'unsafe-inline' 'unsafe-eval'; child-src https: data: blob:; connect-src https: data: blob:; font-src https: data:; img-src https: blob: data:; media-src blob: data: https:; object-src https:; script-src https: data: blob: 'unsafe-inline' 'unsafe-eval'; style-src https: 'unsafe-inline'; block-all-mixed-content; upgrade-insecure-requests; report-uri https://capture.condenastdigital.com/csp/wired"
);
"x-access" = (
n
);
"x-amp-backend-override" = (
false
);
"x-cache" = (
MISS
);
"x-cache-hits" = (
0
);
"x-developers" = (
"Conde Nast is hiring. http://www.condenast.com/careers"
);
"x-format" = (
article
);
"x-id" = (
5b997578f3be4b741fa986e3
);
"x-section" = (
science
);
"x-served-by" = (
"cache-cdg20728-CDG"
);
"x-timer" = (
"S1537031927.890618,VS0,VE451"
);
"x-type" = (
article
);
}}