So I’ve been hoping that NSURLSessionStreamTask would make it easier to 
implement WebSockets by allowing me to make the initial HTTP handshake as a 
regular HTTP request with an NSURLSessionDataTask, then switch to a raw stream 
by returning NSURLSessionResponseBecomeStream from the response delegate method.

I just tried it (on macOS 10.12.4 beta 4) and unfortunately it doesn’t work. 
Upgrading protocols requires that the value of the request's “Connection:” 
header be “Upgrade", but the value gets changed to “keep-alive” when sent, 
causing the server to reject the request. I assume this is one of those headers 
that the client can’t control. :(

I can instead create the task as a stream from the beginning by calling 
-streamTaskWithHostName:port:. But then I’m basically working with raw TCP, so 
I need to construct and parse the HTTP messages myself, and more importantly, I 
lose SSL support and the semi-automatic handling of proxies, redirects and auth 
challenges. (It’s really no better than NSStream.)

Is this something that could be fixed in the future, or is it considered a 
non-feature for NSURLSession to allow HTTP connection upgrades?

—Jens
 _______________________________________________
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