Bug 140571 - Provide hook to alter (or at least add headers to) URL requests initiated from WKWebView
Summary: Provide hook to alter (or at least add headers to) URL requests initiated fro...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: iPhone / iPad All
: P2 Enhancement
Assignee: Nobody
Keywords: InRadar
Depends on:
Reported: 2015-01-16 15:43 PST by Stuart Morgan
Modified: 2016-08-28 09:28 PDT (History)
8 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Morgan 2015-01-16 15:43:55 PST
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.
Comment 1 Stuart Morgan 2015-06-01 11:15:42 PDT
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.
Comment 2 Stuart Morgan 2015-06-02 11:24:23 PDT
I forgot to note that this is rdar://19506439
Comment 3 Mike West 2015-09-04 06:40:00 PDT
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?
Comment 4 Mike West 2016-01-29 00:29:44 PST
John, Brent, perhaps one of you could route this to interested folks?