Re: POST with file and bytes written
Re: POST with file and bytes written
- Subject: Re: POST with file and bytes written
- From: Frederick Cheung <email@hidden>
- Date: Sun, 27 Nov 2005 13:39:02 +0000
On 27 Nov 2005, at 12:37, Fielke Gary wrote:
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?
You can look at the source for CFNetwork: http://
darwinsource.opendarwin.org/10.4.2/CFNetwork-128.2/HTTP/CFHTTPStream.c
You can see that kCFStreamPropertyHTTPRequestBytesWrittenCount just
returns the variable requestBytesWritten, which is incremented with
the result of CFWriteStreamWrite.
Scanning over the cfstream coding, it looks like any buffering that
is happening is at the level of the kernel's buffers.
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden