Re: NSURLSessionStreamTask and HTTP(S) proxies
Re: NSURLSessionStreamTask and HTTP(S) proxies
- Subject: Re: NSURLSessionStreamTask and HTTP(S) proxies
- From: "Quinn \"The Eskimo!\"" <email@hidden>
- Date: Tue, 07 Feb 2017 08:57:39 +0000
On 6 Feb 2017, at 10:33, Thibault Martin-Lagardette <email@hidden> wrote:
> I find this highly surprising, as it is absolutely possible to use an HTTP(S) proxy for raw TCP/IP connections, simply by using the HTTP CONNECT method (RFC 2817 <https://tools.ietf.org/html/rfc2817>)
Indeed. And NSURLSession will do this for HTTPS requests. I suspect that the fact that it doesn’t do this for stream tasks is more an accident of history than anything else (NSURLSession was originally designed as an HTTP[S] API, and for HTTP it can just use the HTTP proxy in the standard way).
You should feel free to file an enhancement request for this support. Please post your bug number, just for the record.
<https://developer.apple.com/bug-reporting/>
> Because the remote TCP server does not understand HTTP at all, I cannot use an NSURLSessionDataTask to then be converted to a stream task.
But you could do that in the proxy case, no? That is:
1. Make the request via a standard stream task
2. If that fails, look at the system proxy settings (via <CFNetwork/CFProxySupport.h>)
3. If the system is configured to use an HTTP proxy, make a data task to that proxy with the `CONNECT` method
4. If that works, in the response, convert the data task to a stream task
Share and Enjoy
--
Quinn "The Eskimo!" <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden