cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to capture Error message from the Server

From: Ray Satiro via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 17 May 2016 15:18:12 -0400

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://curl.haxx.se/libcurl/c/CURLINFO_RESPONSE_CODE.html
[2]: https://curl.haxx.se/libcurl/c/CURLOPT_FAILONERROR.html

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-05-17