• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLSessionStreamTask and HTTP(S) proxies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

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!" <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
--

Thibault ML


 _______________________________________________
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

  • Follow-Ups:
    • Re: NSURLSessionStreamTask and HTTP(S) proxies
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
References: 
 >NSURLSessionStreamTask and HTTP(S) proxies (From: Thibault Martin-Lagardette <email@hidden>)
 >Re: NSURLSessionStreamTask and HTTP(S) proxies (From: "Quinn \"The Eskimo!\"" <email@hidden>)

  • Prev by Date: Re: NSURLSessionStreamTask and HTTP(S) proxies
  • Next by Date: Re: NSURLSessionStreamTask and HTTP(S) proxies
  • Previous by thread: Re: NSURLSessionStreamTask and HTTP(S) proxies
  • Next by thread: Re: NSURLSessionStreamTask and HTTP(S) proxies
  • Index(es):
    • Date
    • Thread