Skip to content

Commit

Permalink
utils: new parameter http_response_mode to control what response part…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
miconda committed Sep 17, 2015
1 parent bc74d54 commit 7e866d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 10 additions & 8 deletions modules/utils/functions.c
Expand Up @@ -45,6 +45,7 @@


extern int http_response_trim;
extern int http_response_mode;

/*
* curl write function that saves received data as zero terminated
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions modules/utils/utils.c
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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}
};
Expand Down

0 comments on commit 7e866d6

Please sign in to comment.