[OpenSIPS-Users] CURL library with respect to REST_API calls
Ramachandran, Agalya (Contractor)
Agalya_Ramachandran at comcast.com
Fri Jun 24 23:02:53 CEST 2016
Hi Liviu,
I have not changed anything in the write_func(). Also I tried by adding some debug statements.
I observed that only in the case of success write_func() is being called and I get the debug statements in my logs.
In the case of failure, the callback function is never called. This is what I observe.
If you try for failure case, let me know how it worked for you.
Regards,
Agalya
From: users-bounces at lists.opensips.org [mailto:users-bounces at lists.opensips.org] On Behalf Of Liviu Chircu
Sent: Thursday, June 23, 2016 5:52 AM
To: users at lists.opensips.org
Subject: Re: [OpenSIPS-Users] CURL library with respect to REST_API calls
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><mailto: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<mailto: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/20160624/b1fb6a9f/attachment.htm>
More information about the Users
mailing list