lionheart / openradar-mirror

A mirror of radars pulled from http://openradar.me/.
245 stars 17 forks source link

50057283: WKWebView does not support custom headers on outgoing requests #21201

Open openradar-mirror opened 5 years ago

openradar-mirror commented 5 years ago

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) -> ()) 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:

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