Browse code

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)

Daniel-Constantin Mierla authored on 13/08/2019 07:07:34
Showing 3 changed files
... ...
@@ -652,7 +652,7 @@ int http_client_query(
652 652
 	query_params.verify_host = default_tls_verify_host;
653 653
 	query_params.timeout = default_connection_timeout;
654 654
 	query_params.http_follow_redirect = default_http_follow_redirect;
655
-	query_params.oneline = 1;
655
+	query_params.oneline = default_query_result;
656 656
 	query_params.maxdatasize = 0;
657 657
 	if(default_useragent.s != NULL && default_useragent.len > 0) {
658 658
 		query_params.useragent = default_useragent.s;
... ...
@@ -100,6 +100,11 @@ unsigned int default_authmethod =
100 100
 		CURLAUTH_BASIC
101 101
 		| CURLAUTH_DIGEST; /*!< authentication method - Basic, Digest or both */
102 102
 
103
+/*!< Default http query result mode
104
+ * - 0: return full result
105
+ * - 1: return first line only */
106
+unsigned int default_query_result = 1;
107
+
103 108
 str http_client_config_file = STR_NULL;
104 109
 
105 110
 static curl_version_info_data *curl_info;
... ...
@@ -195,6 +200,7 @@ static param_export_t params[] = {
195 195
 	{"httpcon",  PARAM_STRING|USE_FUNC_PARAM, (void*)curl_con_param},
196 196
 	{"authmethod", PARAM_INT, &default_authmethod },
197 197
 	{"keep_connections", PARAM_INT, &default_keep_connections },
198
+	{"query_result", PARAM_INT, &default_query_result },
198 199
 	{0, 0, 0}
199 200
 };
200 201
 
... ...
@@ -62,6 +62,7 @@ extern unsigned int
62 62
 		default_authmethod; /*!< authentication method - Basic, Digest or both */
63 63
 extern unsigned int
64 64
 		default_keep_connections; /*!< Keep http connections open for reuse */
65
+extern unsigned int default_query_result; /*!< Default query result mode */
65 66
 
66 67
 extern counter_handle_t connections; /* Number of connection definitions */
67 68
 extern counter_handle_t connok;		 /* Successful Connection attempts */