[OpenSIPS-Users] CURL library with respect to REST_API calls

Liviu Chircu liviu at opensips.org
Thu Jun 23 11:51:31 CEST 2016


Hi, Ramachandran!

I read the "CURLOPT_WRITEFUNCTION" section [1] one more time, and it 
really looks like it should pass the body of the reply to the 
"write_func" callback we register before sending the HTTP PUT, even if 
we got an error code (3XX or higher).

Did you change anything in the "write_func()"? Notice how their docs say 
that if a proper "len" is not returned, the transfer will be aborted. 
Apart from that, I have no other ideas for now but to try and fetch the 
body myself on an error HTTP ret code of a CUROPT_PUT operation, see how 
(or if) it works for me, and give you more feedback.

[1]: https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html

All the best,

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com

On 22.06.2016 20:19, Ramachandran, Agalya (Contractor) wrote:
>
> Hi team,
>
> Any one has any clue on the below topic?
>
> Regards,
> Agalya
>
> *From:* Ramachandran, Agalya (Contractor)
> *Sent:* Monday, June 20, 2016 1:45 PM
> *To:* OpenSIPS users mailling list <users at lists.opensips.org>
> *Subject:* CURL library with respect to REST_API calls
>
> Hi team,
>
> I have a question regarding curl library behavior with respect to 
> curl_easy_perform API call.
>
> Here is the snippet of the code that am using in “rest_put” API call 
> in rest_methods.c file
>
> /w_curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_func);/
>
> / w_curl_easy_setopt(handle, CURLOPT_WRITEDATA, &res_body);/
>
> //
>
> When curl_easy_perform API call is success, I could able to retrieve 
> the result body from the *res_body*.
>
> But in the case of API call failure am not getting any details of the 
> message. But getting only the http response code.
>
> Is there a way to get the message details as well in the case where 
> curl_easy_perform API fails?
>
> LM_INFO(" Actual result body is %s\n", res_body.s);
>
> When I print this, in the case of success, am getting a http response 
> message in detail.
>
> But in case of failure, the call back function /write_func /is not at 
> all called. Why it is so?
>
> Please guide me if there is a way to the message details in case of 
> failure too.
>
> Regards,
> Agalya
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20160623/9e93d5c4/attachment-0001.htm>


More information about the Users mailing list