views:

270

answers:

2

The app is downloading a file (plist) which is generated by the server. The server takes a loooong time to generate the file, so I would like to be able to show progress (probably view UIProgressView, but that's not important).

Since the file I'm downloading hasn't been created yet at the beginning of the request, we don't know the expectedContentLength. However, I have the means to provide progress updates from the [PHP] script itself. I'm using ob_flush() for each line in the file to do this, which works just fine in a browser.

But when I make the request from the app, I'm only getting a call from connection:didReceiveData: after the script has finished executing, so that's not of much use.

So my question boils down to this:
How can I tap into the progress of such a php script from my app?

I wouldn't mind sending 2 requests to the server, the first that generates the file and provides updates while doing so, and then another to download the actual file.

Since none of my NSUrlConnection delegate methods are being called until the request completes, what does my script need to do to trigger these methods?

+1  A: 

Your problem is most likely on the server. If the server is sending data as it is processed and that processing takes a significant amount of time, you should probably get more than one notification of connection:didReceiveData:.

There is some discussion that might be relevant in the PHP manual. http://php.net/manual/en/function.ob-flush.php

I would verify using a packet analyzer that the server is actually sending data incrementally as you expect.

Andrew Pouliot
ob_flush() works for me in the browser; I get incremental updates. However when making the request from the app, I get everything in one chunk.
Kelso.b
WiFi or 3G? What time scale are we talking here; does the script take like 1 second, or > 10s?
Andrew Pouliot
A: 

look here

sakrist
That's not going to help - the asker's problem is on the server side.
Mark Bessey