Module: kamailio
Branch: master
Commit: 00198b8d863a94ea593b7473c88c35e6cad67014
URL:
https://github.com/kamailio/kamailio/commit/00198b8d863a94ea593b7473c88c35e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2024-04-07T10:41:22+02:00
http_client: added http_client_response_headers_set(mode)
- control if http response header should be set or not
---
Modified: src/modules/http_client/http_client.c
---
Diff:
https://github.com/kamailio/kamailio/commit/00198b8d863a94ea593b7473c88c35e…
Patch:
https://github.com/kamailio/kamailio/commit/00198b8d863a94ea593b7473c88c35e…
---
diff --git a/src/modules/http_client/http_client.c
b/src/modules/http_client/http_client.c
index 4bea581d50f..c8af2f64901 100644
--- a/src/modules/http_client/http_client.c
+++ b/src/modules/http_client/http_client.c
@@ -158,6 +158,8 @@ static int w_http_query_request(struct sip_msg *_m, char *_met, char
*_url,
char *_body, char *_hdrs, char *_result);
static int w_http_query_request_v2pk(struct sip_msg *_m, char *_met, char *_url,
char *_body, char *_hdrs, char *_result);
+static int w_http_client_response_headers_set(
+ sip_msg_t *_m, char *_pval, char *_p2);
/* forward function */
static int curl_con_param(modparam_t type, void *val);
@@ -200,6 +202,9 @@ static cmd_export_t cmds[] = {
{"http_get_redirect", (cmd_function)w_curl_get_redirect, 2,
fixup_curl_get_redirect,
fixup_free_curl_get_redirect,
REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
+ {"http_client_response_headers_set",
+ (cmd_function)w_http_client_response_headers_set, 1, fixup_igp_null,
+ fixup_free_igp_null, ANY_ROUTE},
{"bind_http_client", (cmd_function)bind_httpc_api, 0, 0, 0, 0},
{0,0,0,0,0,0}
};
@@ -1149,6 +1154,36 @@ static int w_http_query_request(sip_msg_t *_m, char *_met, char
*_url,
return ki_http_request_helper(_m, &met, &url, &body, &hdrs, 0, dst);
}
+/*!
+ *
+ */
+static int ki_http_client_response_headers_set(sip_msg_t *_m, int ival)
+{
+ if(ival == 0) {
+ http_client_response_headers_reset();
+ http_client_response_headers_param = 0;
+ } else {
+ http_client_response_headers_param = 1;
+ }
+
+ return 1;
+}
+
+/*!
+ *
+ */
+static int w_http_client_response_headers_set(
+ sip_msg_t *_m, char *_pval, char *_p2)
+{
+ int ival = 0;
+
+ if(fixup_get_ivalue(_m, (gparam_t *)_pval, &ival) < 0) {
+ LM_ERR("failed to get parameter value\n");
+ return -1;
+ }
+ return ki_http_client_response_headers_set(_m, ival);
+}
+
/*!
* Parse arguments to pv $curlerror
*/