[OpenSIPS-Devel] [opensips] rest_get doesn't return information about error (#480)

philevans notifications at github.com
Fri Apr 24 16:23:52 CEST 2015


In the documentation for rest_get in the rest_client module, the example suggests that if an error is returned such as a 403 or a 404, the rest_get call will return false, and you will still have access to the return code and body:

    # Example of querying a REST service to get the credit of an account
    
    if (!rest_get("http://getcredit.org/?ruri=$fU", "$var(credit)", "$var(ct)", "$var(rcode)")) {
      xlog("Error code $var(rcode) in HTTP GET!\n");
      send_reply("403", "Not registered");
      exit;
    }

However this does not work for me, and the OpenSIPS log just shows an error, and none of the PVs are populated with the return code or body.  Looking at the code, I see CURLOPT_FAILONERROR is set, which means it just fails outright of a response code >=400 is returned.  Also as far as I can tell even if this wasn't set, the code would then just incorrectly suggest the call returned OK and populate the PVs.  It needs to do a bit of both, and return a false from the function, but still fill in the PVs.

I am just wondering if this is something I am not doing right, or if this is indeed a bug.

---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/480
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20150424/68f73671/attachment.htm>


More information about the Devel mailing list