Swift Session.dataTask自动更改https-->;http和缺少的查询参数
我一直试图传递一个带有查询参数的URL,但收到一个错误消息:“应用程序传输安全性已阻止明文HTTP(HTTP://)资源加载,因为它不安全。”当我将异常添加到Info.plist时,URL缺少查询参数Swift Session.dataTask自动更改https-->;http和缺少的查询参数,swift,Swift,我一直试图传递一个带有查询参数的URL,但收到一个错误消息:“应用程序传输安全性已阻止明文HTTP(HTTP://)资源加载,因为它不安全。”当我将异常添加到Info.plist时,URL缺少查询参数 为什么URL方案从https更改为http 为什么查询参数没有随请求一起发送 print(url.absoluteString)返回正确的结果。如果我打印出dataTask响应,我会得到以下结果,其中不包括slug query参数 Optional<NSURLResponse> -
Optional<NSURLResponse>
- some : <NSHTTPURLResponse: 0x60000242c820> { URL: https://www.doctorofcredit.com/wp-json/wp/v2/posts } { Status Code: 200, Headers {
"Cache-Control" = (
"max-age=10800, must-revalidate"
);
"Content-Encoding" = (
gzip
);
"Content-Type" = (
"application/json; charset=UTF-8"
);
Date = (
"Thu, 15 Oct 2020 18:02:34 GMT"
);
Link = (
"<https://www.doctorofcredit.com/wp-json/wp/v2/posts?page=2>; rel=\"next\""
);
Server = (
nginx
);
Vary = (
"Accept-Encoding",
"Accept-Encoding"
);
"access-control-allow-headers" = (
"Authorization, Content-Type"
);
"access-control-expose-headers" = (
"X-WP-Total, X-WP-TotalPages"
);
allow = (
GET
);
"content-security-policy" = (
"upgrade-insecure-requests;"
);
"x-cache" = (
"HIT: 1"
);
"x-cache-group" = (
bot
);
"x-cacheable" = (
bot
);
"x-content-type-options" = (
nosniff
);
"x-powered-by" = (
"WP Engine"
);
"x-robots-tag" = (
noindex
);
"x-wp-total" = (
21374
);
"x-wp-totalpages" = (
2138
);
} }
可选
-一些:{URL:https://www.doctorofcredit.com/wp-json/wp/v2/posts }{状态代码:200,标题{
“缓存控制”=(
“最大年龄=10800,必须重新验证”
);
“内容编码”=(
gzip
);
“内容类型”=(
“application/json;charset=UTF-8”
);
日期=(
“周四,2020年10月15日18:02:34 GMT”
);
链接=(
“rel=\”下一步“
);
服务器=(
nginx
);
变化=(
“接受编码”,
“接受编码”
);
“访问控制允许标头”=(
授权,内容类型
);
“访问控制公开标头”=(
“X-WP-Total,X-WP-TotalPages”
);
允许=(
得到
);
“内容安全策略”=(
“升级不安全的请求;”
);
“x-cache”=(
“命中率:1”
);
“x-cache-group”=(
机器人程序
);
“x-可缓存”=(
机器人程序
);
“x-content-type-options”=(
诺斯尼夫
);
“x-powered-by”=(
“可湿性粉剂发动机”
);
“x-robots-tag”=(
诺因迪斯
);
“x-wp-total”=(
21374
);
“x-wp-totalpages”=(
2138
);
} }
Optional<NSURLResponse>
- some : <NSHTTPURLResponse: 0x60000242c820> { URL: https://www.doctorofcredit.com/wp-json/wp/v2/posts } { Status Code: 200, Headers {
"Cache-Control" = (
"max-age=10800, must-revalidate"
);
"Content-Encoding" = (
gzip
);
"Content-Type" = (
"application/json; charset=UTF-8"
);
Date = (
"Thu, 15 Oct 2020 18:02:34 GMT"
);
Link = (
"<https://www.doctorofcredit.com/wp-json/wp/v2/posts?page=2>; rel=\"next\""
);
Server = (
nginx
);
Vary = (
"Accept-Encoding",
"Accept-Encoding"
);
"access-control-allow-headers" = (
"Authorization, Content-Type"
);
"access-control-expose-headers" = (
"X-WP-Total, X-WP-TotalPages"
);
allow = (
GET
);
"content-security-policy" = (
"upgrade-insecure-requests;"
);
"x-cache" = (
"HIT: 1"
);
"x-cache-group" = (
bot
);
"x-cacheable" = (
bot
);
"x-content-type-options" = (
nosniff
);
"x-powered-by" = (
"WP Engine"
);
"x-robots-tag" = (
noindex
);
"x-wp-total" = (
21374
);
"x-wp-totalpages" = (
2138
);
} }