Does NSURLSession support http2 bidirectional streams?

Hi,

Does NSURLSession support http2 streams? If not, is there any recommended way to do it?

Looks like NSURLSessionStreamTask can provide a TCP/IP connection, can I use swift-nio-http2 to parse my http requests and make a streaming call with NSURLSessionStreamTask?

Looks like NSURLSessionStreamTask can provide a TCP/IP connection,
can I use swift-nio-http2 to parse my http requests and make a
streaming call with NSURLSessionStreamTask?

That would be kinda pointless. If you’re going to do your own HTTP/2 framing you might as well use NWConnection for the TCP transport (which SwiftNIO will do automatically if you’re on an Apple platform).

However, that seems like overkill. In most cases you can:
  • Stream data from a server by configuring it to to use chunked encoding

  • Stream data to a server by setting the request’s body to a stream (using httpBodyStream), which again will trigger chunked encoding

In the second case, you can either use a custom input steram subclass or use a bound pair of streams.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Does NSURLSession support http2 bidirectional streams?
 
 
Q