cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to capture Error message from the Server

From: Colin Ngam <Colin.Ngam_at_quantum.com>
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.

Thanks.

Clin

From: curl-library <curl-library-bounces_at_cool.haxx.se<mailto:curl-library-bounces_at_cool.haxx.se>> on behalf of Ray Satiro via curl-library <curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>>
Reply-To: libcurl development <curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>>
Date: Tuesday, May 17, 2016 at 3:19 PM
To: libcurl development <curl-library_at_cool.haxx.se<mailto:curl-library_at_cool.haxx.se>>
Cc: Ray Satiro <raysatiro_at_yahoo.com<mailto:raysatiro_at_yahoo.com>>
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.


[1]: http://xmlsoft.org/html/libxml-parser.html#xmlReadMemory<https://urldefense.proofpoint.com/v2/url?u=http-3A__xmlsoft.org_html_libxml-2Dparser.html-23xmlReadMemory&d=CwMDaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=GgZxxOrjo7rUSi2a3aY7DXfeWcIXQ3Xn4a7ByYeR4wA&m=A6ahqpUAvr9Y_2tm4cBAYbn41KgLoiV59Y3TyYWzCXY&s=wC99_32Sew_R5q-Xr6yg8vrvyayC_4qvaZZsn7XE0U0&e=>
[2]: http://www.xmlsoft.org/examples<https://urldefense.proofpoint.com/v2/url?u=http-3A__www.xmlsoft.org_examples&d=CwMDaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=GgZxxOrjo7rUSi2a3aY7DXfeWcIXQ3Xn4a7ByYeR4wA&m=A6ahqpUAvr9Y_2tm4cBAYbn41KgLoiV59Y3TyYWzCXY&s=d625tljkvVpxtu5joA2s6NwerCefgfmksZgJkNpM-6A&e=>

----------------------------------------------------------------------
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: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-17