How to attach proxy for a webview?

All the requests made by my app must pass through a proxy. I am able to do that for a request made by NSUrlSession using the API's

(ex :

configuration.connectionProxyDictionary = proxyDict;
)

How do I achieve the same for a request made by a webview(

[self.webView loadRequest:request];
)


Thanks!!

Accepted Reply

There isn’t a good way to do this. For UIWebView you can use an NSURLProtocol (as illustrated by the CustomHTTPProtocol sample code) but it’s a bunch of work and has a lot of sharp edge cases.

For WKWebView, which is what we recommend that folks use, the networking is done out of process and thus the NSURLProtocol technique does not work.

Regardless of what else you do here, you should file an enhancement request for direct support for this in WKWebView. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

There isn’t a good way to do this. For UIWebView you can use an NSURLProtocol (as illustrated by the CustomHTTPProtocol sample code) but it’s a bunch of work and has a lot of sharp edge cases.

For WKWebView, which is what we recommend that folks use, the networking is done out of process and thus the NSURLProtocol technique does not work.

Regardless of what else you do here, you should file an enhancement request for direct support for this in WKWebView. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Okay Eskimo, Will do that