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

Ramachandran, Agalya (Contractor) Agalya_Ramachandran at comcast.com
Wed Jul 6 21:13:48 CEST 2016


Hi Liviu,

On the below topic, I have double checked that call back function is not at called in the case of failure response.
This is confirmed by adding some debug statements in write_func(). I have not made any changes with respect to functionality.
Only in success case I could able to see the call back called.
I could also confirm by seeing the Wireshark traces am getting response body in the case of failure as well.

In our case since call back function is not called, hence no response body is returned.
Can you please check in your end whether call back is called in the case when curl_easy_perform fails.

Regards,
Agalya

From: Ramachandran, Agalya (Contractor)
Sent: Friday, June 24, 2016 5:03 PM
To: OpenSIPS users mailling list <users at lists.opensips.org>
Subject: RE: [OpenSIPS-Users] CURL library with respect to REST_API calls

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> [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<mailto: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/20160706/ec910020/attachment-0001.htm>


More information about the Users mailing list