I have a UIWebView with some static HTML. I want to get the response headers for the img from that html.
code:
let html = "<html><body><img src=\"\(imageUrl)\" alt=\"test\" width=\"70\" height=\"70\"></body></html>"
webView.loadHTMLString(html, baseURL: nil)
extension ViewController: UIWebViewDelegate {
func webViewDidFinishLoad(_ webView: UIWebView) {
if let html = webView.stringByEvaluatingJavaScript(from: "document.body.innerHTML") {
print("html: \(html)")
}
print("finish load")
let res = URLCache.shared.cachedResponse(for: webView.request!)
print("res: \(res)")
print("headers: \(res?.response)")
}
}
the cached response is always nil.
Is there a way to get the headers?
Thanks