Thank you for the quick reply.

I've filed rdar://30396646 (
https://openradar.appspot.com/radar?id=4935346265522176) for this issue.

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?

I've tried using a URL request to
http://127.0.0.1:8888/smtp-relay.gmail.com:587 , but the HTTP request that
was then created was:
CONNECT /smtp-relay.gmail.com:587 HTTP/1.1
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!" <eski...@apple.com> wrote:


On 6 Feb 2017, at 10:33, Thibault Martin-Lagardette <thibault...@gmail.com>
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      (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/thibault.ml%40gmail.com

This email sent to thibault...@gmail.com

-- 

Thibault ML
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to