Module: kamailio
Branch: master
Commit: be677c2f8930f967277438b7b661baeacd7a5a53
URL:
https://github.com/kamailio/kamailio/commit/be677c2f8930f967277438b7b661bae…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-06-27T11:35:34+02:00
http_client: removed unnecessary cloning of proxy parameter
- the value is already zero terminated and this way avoid memory leak
- wrap returning code to cfg in order to avoid 0 values
---
Modified: modules/http_client/functions.c
Modified: modules/http_client/http_client.c
---
Diff:
https://github.com/kamailio/kamailio/commit/be677c2f8930f967277438b7b661bae…
Patch:
https://github.com/kamailio/kamailio/commit/be677c2f8930f967277438b7b661bae…
---
diff --git a/modules/http_client/functions.c b/modules/http_client/functions.c
index 332f625..258508d 100644
--- a/modules/http_client/functions.c
+++ b/modules/http_client/functions.c
@@ -554,7 +554,8 @@ int curl_con_query_url_f(struct sip_msg* _m, const str *connection,
const str* u
}
/* Wrapper */
-int curl_con_query_url(struct sip_msg* _m, const str *connection, const str* url, str*
result, const char *contenttype, const str* post)
+int curl_con_query_url(struct sip_msg* _m, const str *connection,
+ const str* url, str* result, const char *contenttype, const str* post)
{
return curl_con_query_url_f(_m, connection, url, result, contenttype, post, 0);
}
@@ -586,8 +587,12 @@ int http_query(struct sip_msg* _m, char* _url, str* _dst, char*
_post)
query_params.http_follow_redirect = default_http_follow_redirect;
query_params.oneline = 1;
query_params.maxdatasize = 0;
- query_params.http_proxy = as_asciiz(&default_http_proxy);
- query_params.http_proxy_port = default_http_proxy_port;
+ if(default_http_proxy.s!=NULL && default_http_proxy.len>0) {
+ query_params.http_proxy = default_http_proxy.s;
+ if(default_http_proxy_port>0) {
+ query_params.http_proxy_port = default_http_proxy_port;
+ }
+ }
res = curL_query_url(_m, _url, _dst, &query_params);
diff --git a/modules/http_client/http_client.c b/modules/http_client/http_client.c
index 8c2cab9..5e8fc24 100644
--- a/modules/http_client/http_client.c
+++ b/modules/http_client/http_client.c
@@ -530,7 +530,7 @@ static int w_curl_connect(struct sip_msg* _m, char* _con, char * _url,
char* _re
if (result.s != NULL)
pkg_free(result.s);
- return ret;
+ return (ret==0)?-1:ret;
}
/*
@@ -573,7 +573,7 @@ static int w_curl_connect_post(struct sip_msg* _m, char* _con, char *
_url, char
if (result.s != NULL)
pkg_free(result.s);
- return ret;
+ return (ret==0)?-1:ret;
}
@@ -615,7 +615,7 @@ static int fixup_free_http_query_post(void** param, int param_no)
if (param_no == 3) {
return fixup_free_pvar_null(param, 1);
}
-
+
LM_ERR("invalid parameter number <%d>\n", param_no);
return -1;
}
@@ -644,7 +644,7 @@ static int w_http_query(struct sip_msg* _m, char* _url, char* _result)
{
if (result.s != NULL)
pkg_free(result.s);
- return ret;
+ return (ret==0)?-1:ret;
}
@@ -676,7 +676,7 @@ static int w_http_query_post(struct sip_msg* _m, char* _url, char*
_post, char*
if (result.s != NULL)
pkg_free(result.s);
- return ret;
+ return (ret==0)?-1:ret;
}
/*!
@@ -688,7 +688,6 @@ static int pv_parse_curlerror(pv_spec_p sp, str *in)
if(sp==NULL || in==NULL || in->len<=0)
return -1;
-
cerr = atoi(in->s);
LM_DBG(" =====> CURL ERROR %d \n", cerr);
sp->pvp.pvn.u.isname.name.n = cerr;