[sr-dev] git:master:d07b522b: http_client: new param query_result

Daniel-Constantin Mierla miconda at gmail.com
Tue Aug 13 09:25:49 CEST 2019


Module: kamailio
Branch: master
Commit: d07b522b927f26b01a24417e0fb9f64c87fb79fb
URL: https://github.com/kamailio/kamailio/commit/d07b522b927f26b01a24417e0fb9f64c87fb79fb

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-08-13T09:07:34+02:00

http_client: new param query_result

- control if the http_client_query() returns only the first line or the
entire result
   - 0: return the entire result
   - 1: return the first line (default, backward compatible)

---

Modified: src/modules/http_client/functions.c
Modified: src/modules/http_client/http_client.c
Modified: src/modules/http_client/http_client.h

---

Diff:  https://github.com/kamailio/kamailio/commit/d07b522b927f26b01a24417e0fb9f64c87fb79fb.diff
Patch: https://github.com/kamailio/kamailio/commit/d07b522b927f26b01a24417e0fb9f64c87fb79fb.patch

---

diff --git a/src/modules/http_client/functions.c b/src/modules/http_client/functions.c
index 695324bf43..05dc827126 100644
--- a/src/modules/http_client/functions.c
+++ b/src/modules/http_client/functions.c
@@ -652,7 +652,7 @@ int http_client_query(
 	query_params.verify_host = default_tls_verify_host;
 	query_params.timeout = default_connection_timeout;
 	query_params.http_follow_redirect = default_http_follow_redirect;
-	query_params.oneline = 1;
+	query_params.oneline = default_query_result;
 	query_params.maxdatasize = 0;
 	if(default_useragent.s != NULL && default_useragent.len > 0) {
 		query_params.useragent = default_useragent.s;
diff --git a/src/modules/http_client/http_client.c b/src/modules/http_client/http_client.c
index 432d71a6c8..fc20b65525 100644
--- a/src/modules/http_client/http_client.c
+++ b/src/modules/http_client/http_client.c
@@ -100,6 +100,11 @@ unsigned int default_authmethod =
 		CURLAUTH_BASIC
 		| CURLAUTH_DIGEST; /*!< authentication method - Basic, Digest or both */
 
+/*!< Default http query result mode
+ * - 0: return full result
+ * - 1: return first line only */
+unsigned int default_query_result = 1;
+
 str http_client_config_file = STR_NULL;
 
 static curl_version_info_data *curl_info;
@@ -195,6 +200,7 @@ static param_export_t params[] = {
 	{"httpcon",  PARAM_STRING|USE_FUNC_PARAM, (void*)curl_con_param},
 	{"authmethod", PARAM_INT, &default_authmethod },
 	{"keep_connections", PARAM_INT, &default_keep_connections },
+	{"query_result", PARAM_INT, &default_query_result },
 	{0, 0, 0}
 };
 
diff --git a/src/modules/http_client/http_client.h b/src/modules/http_client/http_client.h
index d7bb7658f9..7f236dfa7e 100644
--- a/src/modules/http_client/http_client.h
+++ b/src/modules/http_client/http_client.h
@@ -62,6 +62,7 @@ extern unsigned int
 		default_authmethod; /*!< authentication method - Basic, Digest or both */
 extern unsigned int
 		default_keep_connections; /*!< Keep http connections open for reuse */
+extern unsigned int default_query_result; /*!< Default query result mode */
 
 extern counter_handle_t connections; /* Number of connection definitions */
 extern counter_handle_t connok;		 /* Successful Connection attempts */




More information about the sr-dev mailing list