From 7e866d62c52239574c52b5cb7797bfe907925e06 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 17 Sep 2015 19:00:47 +0200 Subject: [PATCH] utils: new parameter http_response_mode to control what response part is returned - if http_response_mode=0, only the first line is returned (like so far) - if http_response_mode=1, all the response is returned - default 0 --- modules/utils/functions.c | 18 ++++++++++-------- modules/utils/utils.c | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/utils/functions.c b/modules/utils/functions.c index 42311509418..115cd14a739 100644 --- a/modules/utils/functions.c +++ b/modules/utils/functions.c @@ -45,6 +45,7 @@ extern int http_response_trim; +extern int http_response_mode; /* * curl write function that saves received data as zero terminated @@ -208,14 +209,15 @@ int http_query(struct sip_msg* _m, char* _url, char* _dst, char* _post, char* _h if(http_response_trim) { trim(&hres); } - /* search for line feed */ - at = memchr(hres.s, (char)10, hres.len); - if (at == NULL) { - /* not found: use whole stream */ - val.rs = hres; - } else { - val.rs.s = hres.s; - val.rs.len = at - hres.s; + val.rs = hres; + if(http_response_mode==0) { + /* only first line - search for line feed */ + at = memchr(hres.s, (char)10, hres.len); + if (at != NULL) { + /* found: use first line */ + val.rs.s = hres.s; + val.rs.len = at - hres.s; + } } LM_DBG("http_query result: %.*s\n", val.rs.len, val.rs.s); val.flags = PV_VAL_STR; diff --git a/modules/utils/utils.c b/modules/utils/utils.c index 08334b6bf76..368f5b9c95f 100644 --- a/modules/utils/utils.c +++ b/modules/utils/utils.c @@ -59,6 +59,7 @@ MODULE_VERSION /* Module parameter variables */ int http_query_timeout = 4; int http_response_trim = 0; +int http_response_mode = 0; static int forward_active = 0; static int mp_max_id = 0; static char* mp_switch = ""; @@ -124,6 +125,7 @@ static param_export_t params[] = { {"xcap_table", PARAM_STR, &xcap_table}, {"http_query_timeout", INT_PARAM, &http_query_timeout}, {"http_response_trim", INT_PARAM, &http_response_trim}, + {"http_response_mode", INT_PARAM, &http_response_mode}, {"forward_active", INT_PARAM, &forward_active}, {0, 0, 0} };