Module: kamailio
Branch: master
Commit: 7e866d62c52239574c52b5cb7797bfe907925e06
URL:
https://github.com/kamailio/kamailio/commit/7e866d62c52239574c52b5cb7797bfe…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2015-09-17T22:23:39+02:00
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
---
Modified: modules/utils/functions.c
Modified: modules/utils/utils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7e866d62c52239574c52b5cb7797bfe…
Patch:
https://github.com/kamailio/kamailio/commit/7e866d62c52239574c52b5cb7797bfe…
---
diff --git a/modules/utils/functions.c b/modules/utils/functions.c
index 4231150..115cd14 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 08334b6..368f5b9 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}
};