<p>
jarrodb wants to merge 1 commit into
OpenSIPS:master from jarrodb:rest_append_hf:
</p>

<p>This is an initial commit to address feature request <a href="https://github.com/OpenSIPS/opensips/issues/496" class="issue-link" title="append HTTP headers with rest_client">#496</a>.</p>

<p>I have tested this module with the following script excerpt:</p>

<h3>request route</h3>

<pre><code>  $json(test) := "{}";
  $json(test/id) = "1";
  route(TEST_POST);
  route(TEST_GET);
  route(TEST_ASYNC_POST);
</code></pre>

<h3>route definitions</h3>

<pre><code>route[TEST_GET] {
  rest_append_hf("Authorization: Bearer mF_9.B5f-4.1JqM");
  if (!rest_get("http://127.0.0.1:3000/",
                 "$var(reply)",
                 "$var(ct)",
                 "$var(rcode)"))
  {
    xlog("Error code $var(rcode) in HTTP GET!\n");
    send_reply("403", "GET Forbidden");
    exit;
  }
  xlog("Successful get - $var(ct) - $var(rcode)\n$var(reply)\n");
}

route[TEST_POST] {
  rest_append_hf("Authorization: Bearer mF_9.B5f-4.1JqM");
  if (!rest_post("http://127.0.0.1:3000/",
                 "$json(test)",
                 "application/json",
                 "$var(post_reply)",
                 "$var(post_ct)",
                 "$var(post_rcode)"))
  {
    xlog("Error code $var(post_rcode) in HTTP POST!\n");
    send_reply("403", "POST Forbidden");
    exit;
  }
  xlog("Successful post - $var(post_ct) - $var(rcode)\n$var(post_reply)\n");
}

route[TEST_ASYNC_POST] {
  rest_append_hf("Authorization: Bearer mF_9.B5f-4.1JqM");
  async(rest_post("http://127.0.0.1:3000/",
                  "$json(test)",
                  "application/json",
                  "$json(async_test_reply)",
                  "$var(async_ct)",
                  "$var(async_rcode)"),
        TEST_ASYNC_POST_REPLY);
}

route[TEST_ASYNC_POST_REPLY] {
  xlog("In TEST_ASYNC_POST_REPLY, reply received: $json(async_test_reply)\n");
}
</code></pre>

<h3>example log output</h3>

<pre><code>May  5 05:45:43 localhost opensips[919]: Successful post - application/json - &lt;null&gt;#012{"id": 1, "result": true}
May  5 05:45:43 localhost opensips[919]: Successful get - text/html - 200#012
May  5 05:45:43 localhost opensips[919]: In TEST_ASYNC_POST_REPLY, reply received: {"id": 1, "result": true}
</code></pre>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>&nbsp;&nbsp;<a href='https://github.com/OpenSIPS/opensips/pull/497'>https://github.com/OpenSIPS/opensips/pull/497</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>moved curl_slist to global process variable to support addition of rest_append_hf command</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/497/files#diff-0">modules/rest_client/rest_cb.h</a>
    (1)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/497/files#diff-1">modules/rest_client/rest_client.c</a>
    (15)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/497/files#diff-2">modules/rest_client/rest_methods.c</a>
    (56)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/OpenSIPS/opensips/pull/497/files#diff-3">modules/rest_client/rest_methods.h</a>
    (2)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/OpenSIPS/opensips/pull/497.patch'>https://github.com/OpenSIPS/opensips/pull/497.patch</a></li>
  <li><a href='https://github.com/OpenSIPS/opensips/pull/497.diff'>https://github.com/OpenSIPS/opensips/pull/497.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/pull/497">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AFOciXfXHH-ZI8tCoyNKI73Cyoj1I6nGks5oGFPLgaJpZM4EP-nu.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/497"></link>
    <meta itemprop="name" content="View Pull Request"></meta>
  </div>
  <meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>