i'm trying to get just the response content, not the headers... from
an HTTP GET ... but CFReadStreamRead() seems to just give me the whole
lot... headers and all.....which probably makes sense, but how to I
extract just the content?
TIA
mlabs - 12 Oct 2007 03:52 GMT
figured it out, so in case anyone is interested..
you can create an empty response object and fill it with the incoming
bytes.. like so:
responseRef = CFHTTPMessageCreateEmpty(NULL, FALSE);
then use CFReadStreamRead in a loop to get the bytes into a temporary
buffer...
as you get the bytes you append them into the empty response object
like so:
CFHTTPMessageAppendBytes(responseRef, (UInt8*)bytes, nBytesRead);
then when all the bytes are in, you use the response object to get the
body content:
CFDataRef respData = CFHTTPMessageCopyBody(responseRef);
if there is a better way please post it
TIA