cURL / Mailing Lists / curl-library / Single Mail


Re: How to capture Error message from the Server

From: Colin Ngam <>
Date: Tue, 17 May 2016 21:24:10 +0000

Hi Ray,

Say, I need to read a file and it has “This is a test.” in it.

I issue a GET for an object in the cloud. My callback is called with “This is a test.” in the buffer. I saved it into a local file. All is fine.

Now, if someone deleted the object. I did not know. I issue a GET. My callback gets:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>smC1842A51E22A05000000000000A386410000000100003J7M3CMY9CMULJKG6Q</Key><RequestId>B09B6836031219A8</RequestId><HostId>GIxwOGJB8DMKoIxYcqNkRDL/a1rcrPyg7hmMx+UNNtvUVgaOILdjCMe/ntfo/+bIxWG1D5ws7SU=</HostId></Error>

In my callback I did not know that this is an error message. I just save it in my local file. Toss my buffer away. Now I get an error return from libcurl with some http error.

So, the question is how do I know my callback has been called with the Server’s extended error message, so that I can save it and not write it to file and toss the buffer away ..



On 5/17/16, 4:06 PM, "curl-library on behalf of Ray Satiro via curl-library" < on behalf of> wrote:

>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:

The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through anti virus and spam software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

List admin:
Received on 2016-05-17