|
@@ -3,6 +3,7 @@
|
|
|
*
|
|
|
* Copyright (C) 2008 Juha Heinanen
|
|
|
* Copyright (C) 2009 1&1 Internet AG
|
|
|
+ * Copyright (C) 2013 Carsten Bock, ng-voice GmbH
|
|
|
*
|
|
|
* This file is part of Kamailio, a free SIP server.
|
|
|
*
|
|
@@ -91,12 +92,19 @@ static void destroy(void);
|
|
|
static int fixup_http_query(void** param, int param_no);
|
|
|
static int fixup_free_http_query(void** param, int param_no);
|
|
|
|
|
|
+/* Wrappers for http_query to be defined later */
|
|
|
+static int w_http_query(struct sip_msg* _m, char* _url, char* _result);
|
|
|
+static int w_http_query_post(struct sip_msg* _m, char* _url, char* _post, char* _result);
|
|
|
+
|
|
|
/* forward function */
|
|
|
int utils_forward(struct sip_msg *msg, int id, int proto);
|
|
|
|
|
|
/* Exported functions */
|
|
|
static cmd_export_t cmds[] = {
|
|
|
- {"http_query", (cmd_function)http_query, 2, fixup_http_query,
|
|
|
+ {"http_query", (cmd_function)w_http_query, 2, fixup_http_query,
|
|
|
+ fixup_free_http_query,
|
|
|
+ REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
|
|
|
+ {"http_query", (cmd_function)w_http_query_post, 3, fixup_http_query,
|
|
|
fixup_free_http_query,
|
|
|
REQUEST_ROUTE|ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE},
|
|
|
{"xcap_auth_status", (cmd_function)xcap_auth_status, 2, fixup_pvar_pvar,
|
|
@@ -325,7 +333,7 @@ static int fixup_http_query(void** param, int param_no)
|
|
|
return fixup_spve_null(param, 1);
|
|
|
}
|
|
|
|
|
|
- if (param_no == 2) {
|
|
|
+ if ((param_no == 2) || (param_no == 3)) {
|
|
|
if (fixup_pvar_null(param, 1) != 0) {
|
|
|
LM_ERR("failed to fixup result pvar\n");
|
|
|
return -1;
|
|
@@ -351,7 +359,7 @@ static int fixup_free_http_query(void** param, int param_no)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- if (param_no == 2) {
|
|
|
+ if ((param_no == 2) || (param_no == 3)) {
|
|
|
return fixup_free_pvar_null(param, 1);
|
|
|
}
|
|
|
|
|
@@ -359,6 +367,20 @@ static int fixup_free_http_query(void** param, int param_no)
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
+/*
|
|
|
+ * Wrapper for HTTP-Query (GET)
|
|
|
+ */
|
|
|
+static int w_http_query(struct sip_msg* _m, char* _url, char* _result) {
|
|
|
+ return http_query(_m, _url, _result, NULL);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+ * Wrapper for HTTP-Query (POST-Variant)
|
|
|
+ */
|
|
|
+static int w_http_query_post(struct sip_msg* _m, char* _url, char* _post, char* _result) {
|
|
|
+ return http_query(_m, _url, _result, _post);
|
|
|
+}
|
|
|
|
|
|
/*!
|
|
|
* \brief checks precondition, switch, filter and forwards msg if necessary
|