We can obtain all of the HTTP header information from WKWebView.
Created
November 18, 2016 00:56
-
-
Save pokk/47137f91670a21ef1a184cccc173194f to your computer and use it in GitHub Desktop.
Obtain http header information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension ViewController: WKNavigationDelegate, WKUIDelegate { | |
func webView(_ webView: WKWebView, decidePolicyFor navigationResponse: WKNavigationResponse, decisionHandler: @escaping (WKNavigationResponsePolicy) -> Swift.Void) { | |
let response = navigationResponse.response as! HTTPURLResponse | |
// Here can get all of the http header infomation after transfer to other view. | |
self.cookie = response.allHeaderFields["Set-Cookie"] as? String | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment