cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Query in curl library behavior when curl_easy_perform fails

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 30 Jun 2016 23:09:51 +0200 (CEST)

On Thu, 30 Jun 2016, Ramachandran, Agalya (Contractor) wrote:

> if there is no response body, call back wont be called right?

If there is no response body, the CURLOPT_WRITEFUNCTION will not be called.

> But I could able to see the response body message in detail in pcap file.

Then you *did* get a response body!

> Only the call back is not called in the case of failure response.

No, that's not how libcurl works. libcurl will call the write callback with
the response body even for "failure responses", if we by that mean non 2xx
HTTP reeponse codes.

If you do get a HTTP response body and libcurl didn't call the write callback,
then there's a bug in there - either in your code or in libcurl.

> Is there a way to retrieve the data when curl_easy_perform fails?

If curl_easy_perform() fails, it did so because something went wrong and then
it returns immediately. Just getting a non-2xx from ta HTTP server is not such
an error condition though.

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