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 19:40:08 +0000

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.

Thanks.

Colin

On 5/17/16, 2:18 PM, "curl-library on behalf of Ray Satiro via curl-library" <curl-library-bounces_at_cool.haxx.se on behalf of curl-library_at_cool.haxx.se> wrote:

>On 5/17/2016 2:36 PM, Colin Ngam wrote:
>> In a PUT situation, you can register a callback to capture any
>> messages from the Server. However, in the case of a GET, since the
>> callback is used for receiving data from the server, how do you get
>> error messages from the Server if any? How do you tell the difference
>> when the callback is called that it is data or an extended error
>> message from the Server?
>
>After curl_easy_perform returns check the HTTP response code [1] in
>addition to its return code. It's also possible to fail on error [2] but
>that closes the connection for each failure (ie another one will be
>opened for the next request to that server), which may not be good
>depending on your circumstances.
>
>
>[1]: https://urldefense.proofpoint.com/v2/url?u=https-3A__curl.haxx.se_libcurl_c_CURLINFO-5FRESPONSE-5FCODE.html&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=GgZxxOrjo7rUSi2a3aY7DXfeWcIXQ3Xn4a7ByYeR4wA&m=lGm8NZjRB-ivjY_hFXbZYz5DR6iJ1UHQ8-hkCnvr1fw&s=L5TIIqTzhn2ZuyVFLpPt_EuDtXYEKypcj96Tfvuvark&e=
>[2]: https://urldefense.proofpoint.com/v2/url?u=https-3A__curl.haxx.se_libcurl_c_CURLOPT-5FFAILONERROR.html&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=GgZxxOrjo7rUSi2a3aY7DXfeWcIXQ3Xn4a7ByYeR4wA&m=lGm8NZjRB-ivjY_hFXbZYz5DR6iJ1UHQ8-hkCnvr1fw&s=ORXSMMmzm0Rawoh-2DM1NZMdpSc-zS0tOQVR8gQGcJ4&e=
>
>-------------------------------------------------------------------
>List admin: https://urldefense.proofpoint.com/v2/url?u=https-3A__cool.haxx.se_list_listinfo_curl-2Dlibrary&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=GgZxxOrjo7rUSi2a3aY7DXfeWcIXQ3Xn4a7ByYeR4wA&m=lGm8NZjRB-ivjY_hFXbZYz5DR6iJ1UHQ8-hkCnvr1fw&s=6jb679K2KWIhtB533ImZXRfex_Bp9dgcush33Gt-jiA&e=
>Etiquette: https://urldefense.proofpoint.com/v2/url?u=https-3A__curl.haxx.se_mail_etiquette.html&d=CwIGaQ&c=8S5idjlO_n28Ko3lg6lskTMwneSC-WqZ5EBTEEvDlkg&r=GgZxxOrjo7rUSi2a3aY7DXfeWcIXQ3Xn4a7ByYeR4wA&m=lGm8NZjRB-ivjY_hFXbZYz5DR6iJ1UHQ8-hkCnvr1fw&s=iirR1Iii0P_xtXLmN66fzadTMuwWJvEuuWk_B0Jlpac&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