Re: NSURLSessionStreamTask and HTTP(S) proxies
Re: NSURLSessionStreamTask and HTTP(S) proxies
- Subject: Re: NSURLSessionStreamTask and HTTP(S) proxies
- From: Thibault Martin-Lagardette <email@hidden>
- Date: Tue, 07 Feb 2017 14:38:22 +0000
Thank you for the quick reply.
As for your suggestion: yes on principle I could potentially do that, but that means handling proxies manually (and handling them changing while the connection is active), which is really what I'm trying to avoid having to do.
That said, from what I've tried, I was unable to actually properly submit a CONNECT request using NSURLSessionDataTask. I set the HTTPMethod property of NSMutableURLRequest to CONNECT, but not sure how I then tell the API which server and port to connect to?
Which is invalid, because of the starting /.
Maybe I'm doing it wrong of course, in which case I'd then love to know of the proper way to issue a CONNECT request using NSURLSessionDataTask!
On Tue, 7 Feb 2017 at 08:57 Quinn "The Eskimo!" <
email@hidden> wrote:
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
--
_______________________________________________
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