There are a variety of cases where it's useful to be able to modify a request being made by a WKWebView. For instance, Chrome for iOS has several features which are based on adding headers to requests to certain servers, for all requests to those servers. Doing this with UIWebView is possible using http/https protocol handlers, but in WKWebView it's apparently impossible to do except for requests that are initiated from outside the web view.
It would be extremely helpful if there were a navigation delegate call (either a change to the existing one, or a new on) that would allow each NSURLRequest to be not just inspected, but potentially modified (at least the headers if not the whole request) before it was issued.
Another case where this has come up is implementing Do Not Track, which requires adding a header to all requests.
Per our offline discussion, a partial solution that avoids synchronous communication back would be just a way to register a server->header map (with wildcards), that would cause all future requests to those servers to add the corresponding headers. It doesn't address all use cases, but would be a significant improvement.
I forgot to note that this is rdar://19506439
This is apparently making Mozilla's foray into iOS a bit more difficult as well: https://mail.mozilla.org/pipermail/mobile-firefox-dev/2014-December/000993.html
Alexey, could you help triage this to folks who might be able to look at the exposed API surface?
John, Brent, perhaps one of you could route this to interested folks?