cURL / Mailing Lists / curl-library / Single Mail


Re: How to capture Error message from the Server

From: Colin Ngam <>
Date: Tue, 17 May 2016 20:42:25 +0000

Hi Ray,

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.

This does not seem efficient because at every callback I have to do a string compare.

In the PUT case, there is no problem because when the read callback is called, it is always some message from the Server.



From: curl-library <<>> on behalf of Ray Satiro via curl-library <<>>
Reply-To: libcurl development <<>>
Date: Tuesday, May 17, 2016 at 3:19 PM
To: libcurl development <<>>
Cc: Ray Satiro <<>>
Subject: Re: How to capture Error message from the Server

On 5/17/2016 3:40 PM, Colin Ngam wrote:

Yes, but if the Server is also sending additional text of the error where can I capture this in the situation of the GET e.g.
<?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>

Currently, what we are doing is comparing the string "<?xml version=“ and saving the buffer just in case of an error overtime the callback is entered.

You'll have to parse that using an XML parser (eg xmlReadMemory [1][2] in libxml2), libcurl doesn't do that for you.


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