I'm talking about using the proxy settings under "System Preferences" : Network : Advanced : Proxies. You can read the information from there using the System Configuration library. I got some questions on these:
- The System Configuration dictionary has the values for the "Exclude Simple Hostnames" and "Bypass proxy settings for these Hosts & Domains", but how do you actually use them to check if a target server should be channeled through a proxy?
- The proxy server entry has a hostname and port, and optionally a username & password. I think the System Configuration dictionary only has the hostname & port. How can I tell if there's also a username & password? And where and what those values are? I guess the user's Keychain database is involved.
- How do you send the channling request to the proxy server? Isn't the HTTP CONNECT command involved? But how do I put the host, port, username, and password into the URLRequest object?
(I thought there were posts about these things in an old Apple developer mailing list many years ago, but I can't find where.)
Can the proxy-to-NSSessionStreamTask process described towards the end of WWDC 2015 Session 711 ("Networking with NSURLSession") be used with these classic proxies? The presenters had code like:
func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveResponse response: NSURLResponse, completionHandler: (NSURLSessionResponseDisposition) -> Void)
{
completionHandler(.BecomeStream)
}
func URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didBecomeStreamTask streamTask: NSURLSessionStreamTask)
{
}
I'm just wondering how to create the proxy-request NSURLSessionDataTask in the first place.
(Based off a StackOverflow post I made at "How is a proxy connection made with URLSession?")