Skip to content

Commit

Permalink
rest_client: Fix incorrect trim operation
Browse files Browse the repository at this point in the history
  • Loading branch information
liviuchircu committed Jul 15, 2016
1 parent c1d56d5 commit d8bf10d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/rest_client/rest_methods.c
Expand Up @@ -407,7 +407,7 @@ int rest_get_method(struct sip_msg *msg, char *url,
long http_rc;
pv_value_t pv_val;
str st = { 0, 0 };
str body = { 0, 0 };
str body = { NULL, 0 }, tbody;

handle = curl_easy_init();
if (!handle) {
Expand Down Expand Up @@ -464,10 +464,11 @@ int rest_get_method(struct sip_msg *msg, char *url,
goto cleanup;
}

trim(&body);
tbody = body;
trim(&tbody);

pv_val.flags = PV_VAL_STR;
pv_val.rs = body;
pv_val.rs = tbody;

if (pv_set_value(msg, body_pv, 0, &pv_val) != 0) {
LM_ERR("Set body pv value failed!\n");
Expand Down Expand Up @@ -515,7 +516,7 @@ int rest_post_method(struct sip_msg *msg, char *url, char *body, char *ctype,
CURL *handle = NULL;
long http_rc;
str st = { 0, 0 };
str res_body = { 0, 0 };
str res_body = { NULL, 0 }, tbody;
pv_value_t pv_val;

handle = curl_easy_init();
Expand Down Expand Up @@ -581,10 +582,11 @@ int rest_post_method(struct sip_msg *msg, char *url, char *body, char *ctype,
goto cleanup;
}

trim(&res_body);
tbody = res_body;
trim(&tbody);

pv_val.flags = PV_VAL_STR;
pv_val.rs = res_body;
pv_val.rs = tbody;

if (pv_set_value(msg, body_pv, 0, &pv_val) != 0) {
LM_ERR("Set body pv value failed!\n");
Expand Down

0 comments on commit d8bf10d

Please sign in to comment.