I'm uploading a file from an iPhone to a server with an HTTP POST, and monitoring the progress in NSURLConnection's connection:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite. The problem is that the progress is not smooth. The beginning of the file goes by very fast in four 32K chunks, then the progress ticks by more slowly with smaller chunks until the total is reached. Then didSendBodyData doesn't get called anymore for some time before the response finally comes back. The progress bar being driven by the code therefore goes fast (almost instantaneously) for the first 128K, then slow, then "sticks" at 100% for a long time.
Some research implies that the first four chunks are instantly going into the phone's "kernel buffer," and from then on data trickles into the buffer as data trickles out the other end. Progress reaches 100% when the last of the data trickles in, but then sticks while the buffer empties on the back side.
I'd much prefer to show progress based on the data coming out the back end, or not have a buffer at all. Anyone know how I can do this?