On 5/17/2016 4:42 PM, Colin Ngam wrote:
Yes, I understand that part after I get the content.

In a GET situation my callback gets called by libcurl with data:
1st Call – I save the data.
2nd Call – I save the data.
3rd Call – I save the data.
Done. Good.

Now, if the Server has an error after the 2nd call, the 3rd call comes in, I do not know that it is an error message, I save and toss buffer. Save means write to file. Now I get an error condition status.

What I am doing right now is that at each of the Call above, I compare the buffer for "<?xml version=“ and if it compares, I save it off to an error buffer just in case.

Please do not top post it makes the conversation harder to follow [1].

I'm not sure I understand what you mean. To copy and paste from another topic I just replied to: The write function is passed as much data as available when it's called [2]. It will likely be called multiple times, each time with a piece of the reply. It's up to your callback to append those pieces. Take a look at the getinmemory example [3].

Once you have received the reply body in full then you can pass it to an XML parser. If you are using a library like libxml2 it is possible to use something like xmlParseChunk [4] instead to pass each chunk from the write callback as it is received.


[1]: https://curl.haxx.se/mail/etiquette.html#Do_Not_Top_Post
[2]: https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
[3]: https://curl.haxx.se/libcurl/c/getinmemory.html
[4]: http://www.xmlsoft.org/examples/parse4.c

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Reply via email to