cURL / Mailing Lists / curl-library / Single Mail


Re: How to capture Error message from the Server

From: Ray Satiro via curl-library <>
Date: Tue, 17 May 2016 17:06:40 -0400

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.


List admin:
Received on 2016-05-17