<p>Was able to duplicate an error posted to devel mailing list by philevans where if rest_get libcurl returned <code>CURLE_HTTP_RETURNED_ERROR</code> for any status >=400 it returned an error before populating the <code>code_pv</code> pvar even though the rest_client docs show it should be available <a href="http://www.opensips.org/html/docs/modules/devel/rest_client.html#id293741">here</a> like this:</p>
<pre><code>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;
}
</code></pre>
<p>This patch simply moves the code_rv population above the <code>(rc != CURLE_OK)</code> check.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/OpenSIPS/opensips/pull/481'>https://github.com/OpenSIPS/opensips/pull/481</a></p>
<h4>Commit Summary</h4>
<ul>
<li>Populate the rcode pval in rest get/post methods before returning error</li>
</ul>
<h4>File Changes</h4>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/OpenSIPS/opensips/pull/481/files#diff-0">modules/rest_client/rest_methods.c</a>
(53)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/OpenSIPS/opensips/pull/481.patch'>https://github.com/OpenSIPS/opensips/pull/481.patch</a></li>
<li><a href='https://github.com/OpenSIPS/opensips/pull/481.diff'>https://github.com/OpenSIPS/opensips/pull/481.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/481">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciQoEt8Kj4fIJFYXGIzb8D8APHndJks5oCliIgaJpZM4EH9pa.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/OpenSIPS/opensips/pull/481"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>