[英]iOS UIWebView has a blank page when I add cookies to request
When I add cookies header to UIWebView request I get a blank page. 当我向UIWebView请求添加cookie标头时,我得到一个空白页。 It loads page well when there are no cookies header in request.
当请求中没有cookie标头时,它将很好地加载页面。 When I try this request using curl command it loads the page well.
当我使用curl命令尝试此请求时,它将很好地加载页面。
curl --header "Cookie: id=0036100001CWQLFAA5; sn=209caec4cc6d3916186218685c4bea9b1ad4084b; visitor_id290562=124369749; visitor_id290562-hash=262c38ffdae6a7a373cb06ea327cb6bca047b78434f6e15b62f2859c0eab2cd0897a220a4640848783fd8b34008c041eea5adc46" https://ecommerce.thebullbag.com/my-account > Desktop/1.html
This is my Swift code: 这是我的Swift代码:
let url = URL(string: WebSiteUrl + "/my-account")!
let webController = TOWebViewController(url: url)!
webController.urlRequest.addValue("Cookie", forHTTPHeaderField: "id=0036100001CWQLFAA5; sn=209caec4cc6d3916186218685c4bea9b1ad4084b; visitor_id290562=124369749; visitor_id290562-hash=" +
"262c38ffdae6a7a373cb06ea327cb6bca047b78434f6e15b62f2859c0eab2cd0897a220a4640848783fd8b34008c041eea5adc46")
let navigationController = UINavigationController(rootViewController: webController)
self.present(navigationController, animated: true)
When I remove webController.urlRequest.addValue
page is loaded well. 当我删除
webController.urlRequest.addValue
页面时,加载得很好。
I added everything into Info.plist 我将所有内容添加到Info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>ecommerce.thebullbag.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<!--Include to allow HTTP requests-->
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<!--Include to specify minimum TLS version-->
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSAllowsArbitraryLoadsInWebContent</key>
<true/>
</dict>
It was a typo: 这是一个错字:
webController.urlRequest.addValue("id=0036100001CWQLFAA5; sn=209caec4cc6d3916186218685c4bea9b1ad4084b; visitor_id290562=124369749; visitor_id290562-hash=" +
"262c38ffdae6a7a373cb06ea327cb6bca047b78434f6e15b62f2859c0eab2cd0897a220a4640848783fd8b34008c041eea5adc46",
forHTTPHeaderField: "Cookie")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.