Summary: UIWebView supports being able to modify headers on outgoing requests, whereas WKWebView does not. It is possible to achieve a partial solution by overriding webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ()) in WKNavigationDelegate, however this does not cover XMLHttpRequest (XHR) requests, which are very important in single page applications.
This significantly limits the usefulness of WKWebView for some applications. This is a downgrade from UIWebView for this use case.
Steps to Reproduce:
Attempt to apply headers to any outgoing request, for example "x-secret-key": "1234"
Use a web application with XHR requests
Notice your header is not being applied
Expected Results: Header should be applied to all requests.
Actual Results: webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ()) is not invoked for non-XHR requests. This means headers cannot be applied to XHR requests.
Description
Area: WebKit
Summary: UIWebView supports being able to modify headers on outgoing requests, whereas WKWebView does not. It is possible to achieve a partial solution by overriding
webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ())
inWKNavigationDelegate
, however this does not cover XMLHttpRequest (XHR) requests, which are very important in single page applications.This significantly limits the usefulness of WKWebView for some applications. This is a downgrade from UIWebView for this use case.
Steps to Reproduce:
Expected Results: Header should be applied to all requests.
Actual Results: webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ()) is not invoked for non-XHR requests. This means headers cannot be applied to XHR requests.
Version/Build: Any up to and including iOS 12.2
Configuration: Nothing non-standard
- Product Version: 12.2 Created: 2019-04-19T20:33:49.954938 Originated: 2019-04-19T00:00:00 Open Radar Link: http://www.openradar.me/50057283