On May 14, 2012, at 12:50 PM, Jeff Johnson wrote:
Won't CFHTTPMessageCopyBody() give you the partial message body, after CFHTTPMessageIsHeaderComplete() returns true? I'm looking at some HTTP parsing code I wrote a while ago, and it seems to indicate that it should. I'd have to run it through the debugger to confirm, but I'm pretty sure it will.
So you’re saying to call that and parse what’s in it as body, then continue parsing data from the stream myself as the rest of the body?
I don’t think this is going to work correctly if the body is encoded, as it is in my case. What’s going to come out of CopyBody is, presumably, decoded; and it’s not going to be possible in the general case to take decoded partial output and seamlessly continue parsing encoded data.
(For example, in the case of chunk encoding, if the current body data stops halfway through a chunk, I now have no way of knowing how many bytes remain in the chunk because the chunk byte-count was parsed by CFHTTPMessage.)
—Jens