Expected duration: less than 1 week Project Goal: We're looking to achieve the same effect as could previously be achieved in a UIWebView with a URLProtocol/NSURLProtocol. This means: a WKWebView, browsing HTTP/HTTPS, where all content is proxied via a remote HTTP/HTTPS (Squid) proxy server. I understand this is possible using WKWebView using a WKURLSchemeHandler. It's possible to register the WKURLSchemeHandler for http and https using private APIs.
More information: An example project showing this been done (with a number of bugs) is shown here: https://github.com/samheather/iOSHttpProxyDemo
A blog post explaining this can be found here - you may wish to use Google Translate on this page, or refer to the English translation below: Original: https://nemocdz.github.io/post/ios-%E8%AE%BE%E7%BD%AE%E4%BB%A3%E7%90%86proxy%E6%96%B9%E6%A1%88%E6%80%BB%E7%BB%93/ English: https://www.programmersought.com/article/3803634523/
Known bugs with the current solution: 1. If you open WKWebView2VC BEFORE you open UIWebViewVC, the View Controller is unable to open URLs like https://facebook.com (change the URL in the code). I believe this is because the shared URLSession is created differently - and as a result it's unable to handle either HTTPS, or websites with HTTP redirects. 2. I found it necessary to comment out / remote the two calls to "currentSession?.invalidateAndCancel()" - otherwise the app would crash on sites like Facebook.
In the sample app on GitHub, I have provided a test HTTP proxy server (Squid, on port 443) which is configured to allow access to these URLs: .whatismyipaddress.com .whatismyipaddress.info .freedom-apps.com .herokuapp.com .atdmt.com .tenor.co .giphy.com .googleapis.com .googletagmanager.com .akamaihd.net .appspot.com .cdninstagram.com .edgekey.net .edgesuite.com .facebook.com .facebook.net .fb.com .fb.me .fbcdn.com .fbcdn.net .fbsbx.com .instagram.com .online-metrix.net .tfbnw.net .whatsapp.com .messenger.com .ads-twitter.com .t.co .twimg.com .twitter.com .twitter.map.fastly.net .twttr.com .pscp.tv
Acceptance Criteria: 1. A fully-functional self-contained WKURLSchemeHandler (ideally using URLSession and not Alamofire) that proxies all requests via HTTP/HTTPS squid proxy server. 2. Must be possible to integrate with WKWebView via private API as shown in the sample project and GitHub URL above. 3. Must work without first triggering a standalone request via URLProtocol 4. High performance: must support streaming video playback 5. High stability: must support URL redirections, HTTPS, and complex sites like Facebook & Google.
We are open to submissions either of a quote to build an entirely new WKURLSchemeHandler, OR to repair the demo app.