I want keep a NSURLConnection open, and upload data via chunked transfer encoding. I have a buffer that reads in data, and as soon as I read in the data, I want to upload this data. I won't know how much data will be read ahead of time, so I need to keep the connection open.

From what I've seen on Stackoverflow, I've seen recommendations such as setHTTPBodyStream, ASIHTTPRequest, etc. However, I believe all of those does not allow me to add more data to the connection once it's opened.

Is there any way to do this in iOS? Any recommendation is welcome.

Thanks.

有帮助吗?

解决方案

I did not actually try this myself, but have a look at "PostController.m" in the SimpleURLConnections sample project from the Apple Developer Library.

It shows how to create a socket pair where the reading end (consumerStream in the sample code) is used as HTTPBodyStream for the URL request, and you can write your data to the writing end (producerStream).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top