2017-09-19 4 views
1

クッキーヘッダーをUIWebViewリクエストに追加すると、空白のページが表示されます。リクエストにクッキーヘッダーがない場合、ページをうまく読み込みます。 curlコマンドを使用してこのリクエストを試すと、ページがうまく読み込まれます。リクエストするクッキーを追加すると、iOS UIWebViewに空白のページが表示される

curl --header "Cookie: id=0036100001CWQLFAA5; sn=209caec4cc6d3916186218685c4bea9b1ad4084b; visitor_id290562=124369749; visitor_id290562-hash=262c38ffdae6a7a373cb06ea327cb6bca047b78434f6e15b62f2859c0eab2cd0897a220a4640848783fd8b34008c041eea5adc46" https://ecommerce.thebullbag.com/my-account > Desktop/1.html 

これは私のスウィフトコードです:私はwebController.urlRequest.addValueページがうまくロードされ削除すると

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) 

私はそれはタイプミスだったの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> 

答えて

0

にすべてを追加しました:

webController.urlRequest.addValue("id=0036100001CWQLFAA5; sn=209caec4cc6d3916186218685c4bea9b1ad4084b; visitor_id290562=124369749; visitor_id290562-hash=" + 
        "262c38ffdae6a7a373cb06ea327cb6bca047b78434f6e15b62f2859c0eab2cd0897a220a4640848783fd8b34008c041eea5adc46", 
        forHTTPHeaderField: "Cookie") 
関連する問題