I am using a CFHTTPMessageRef and CFReadStreamCreateForHTTPRequest to send a form post with a single file.
The post and file upload work fine, the read stream is scheduled on a run loop and everything looks good. I am wanting to retrieve, during the upload, the file upload progress using the following:
CFNumberRef bytesWritten = (CFNumberRef)CFReadStreamCopyProperty(httpReqStream, kCFStreamPropertyHTTPRequestBytesWrittenCount);
The numbers I get for bytesWritten are a little odd.
a) the first bytesWritten value obtained is always around 67k (unless the size of the file is less than this in which case it will be the file size, say 40k) b) sampling the bytesWritten value every second, it increases as expected until it gets to the message body size (just over the file size) - lets say 150k. c) the file upload hasn't completed yet however, and the following bytesWritten values are fixed at the size of the message body.
So, the values I get for a 150k message body upload by retrieving the bytesWritten every second are the following:
67k, 71k, 74k, 79k.........143k, 147k, 150k, 150k, 150k, 150k, 150k.
For a small file/message body size of say 40k I get:
40k, 40k, 40k.....40k, 40k. (not particularly useful!)
It appears as if the kCFStreamPropertyHTTPRequestBytesWrittenCount property value is NOT returning the number of bytes that have been uploaded but the number of bytes that have been written to a pre-upload buffer of around 64kbytes in size.
Is this exactly what's going on or have I missed something along the way? Has anyone else seen this?
Thanks Gary (running 10.4.3) |