[sr-dev] git:master:1703dda2: curl Add parameter for max download size

Olle E. Johansson oej at edvina.net
Wed Oct 21 07:25:47 CEST 2015


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

Author: Olle E. Johansson <oej at edvina.net>
Committer: Olle E. Johansson <oej at edvina.net>
Date: 2015-10-20T21:54:47+02:00

curl Add parameter for max download size

---

Modified: modules/curl/curl.c
Modified: modules/curl/curl.h
Modified: modules/curl/functions.c

---

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

---

diff --git a/modules/curl/curl.c b/modules/curl/curl.c
index a2c2d74..be2a5b0 100644
--- a/modules/curl/curl.c
+++ b/modules/curl/curl.c
@@ -78,6 +78,7 @@ char 		*default_http_proxy = NULL;		/*!< Default HTTP proxy to use */
 unsigned int	default_http_proxy_port = 0;		/*!< Default HTTP proxy port to use */
 unsigned int	default_http_follow_redirect = 0;	/*!< Follow HTTP redirects CURLOPT_FOLLOWLOCATION */
 char 		*default_useragent = CURL_USER_AGENT;	/*!< Default CURL useragent. Default "Kamailio Curl " */
+unsigned int	default_maxdatasize = 0;		/*!< Default download size. 0=disabled */
 
 static curl_version_info_data *curl_info;
 
@@ -133,16 +134,17 @@ static cmd_export_t cmds[] = {
 
 /* Exported parameters */
 static param_export_t params[] = {
-    	{"connection_timeout", INT_PARAM, &default_connection_timeout},
+    	{"connection_timeout", PARAM_INT, &default_connection_timeout},
 	{"curlcon",  PARAM_STRING|USE_FUNC_PARAM, (void*)curl_con_param},
 	{"tlscacert", PARAM_STRING,  &default_tls_cacert },
 	{"tlsclientcert", PARAM_STRING, &default_tls_clientcert },
 	{"tlsclientkey", PARAM_STRING, &default_tls_clientkey },
-	{"tlsverifyserver", INT_PARAM, &default_tls_verifyserver },
-	{"httpproxyport", INT_PARAM, &default_http_proxy_port },
+	{"tlsverifyserver", PARAM_INT, &default_tls_verifyserver },
+	{"httpproxyport", PARAM_INT, &default_http_proxy_port },
 	{"httpproxy", PARAM_STRING, &default_http_proxy},
-	{"httpredirect", INT_PARAM, &default_http_follow_redirect },
+	{"httpredirect", PARAM_INT, &default_http_follow_redirect },
 	{"useragent", PARAM_STRING,  &default_useragent },
+	{"maxdatasize", PARAM_INT,  &default_maxdatasize },
     	{0, 0, 0}
 };
 
diff --git a/modules/curl/curl.h b/modules/curl/curl.h
index afa296a..b83438c 100644
--- a/modules/curl/curl.h
+++ b/modules/curl/curl.h
@@ -44,6 +44,7 @@ extern char 	*default_http_proxy;			/*!< Default HTTP proxy to use */
 extern unsigned int	default_http_proxy_port;		/*!< Default HTTP proxy port to use */
 extern unsigned int	default_http_follow_redirect;	/*!< Follow HTTP redirects CURLOPT_FOLLOWLOCATION */
 extern char 	*default_useragent;			/*!< Default CURL useragent. Default "Kamailio Curl " */
+extern unsigned int	default_maxdatasize;			/*!< Default Maximum download size */
 
 extern counter_handle_t connections;	/* Number of connection definitions */
 extern counter_handle_t connok;	/* Successful Connection attempts */
@@ -74,6 +75,7 @@ typedef struct _curl_con
 	int http_follow_redirect;	/*!< TRUE if we should follow HTTP 302 redirects */
 	unsigned int port;		/*!< The port to connect to */
 	int timeout;			/*!< Timeout for this connection */
+	long maxdatasize;		/*!< Maximum data download on GET or POST */
 	http_res_stream_t *stream;	/*!< Curl stream */
 	struct _curl_con *next;		/*!< next connection */
 	char redirecturl[512];		/*!< Last redirect URL - to use for $curlredirect(curlcon) pv */
diff --git a/modules/curl/functions.c b/modules/curl/functions.c
index 2baf80f..31034fe 100644
--- a/modules/curl/functions.c
+++ b/modules/curl/functions.c
@@ -247,6 +247,7 @@ int curl_con_query_url(struct sip_msg* _m, char *connection, char* _url, char* _
 	char urlbuf[512];
 	unsigned int len = 0;
 	str postdata;
+	long maxdatasize = default_maxdatasize;
 
 	memset(usernamebuf,0,sizeof(usernamebuf));
 	memset(passwordbuf,0,sizeof(passwordbuf));
@@ -289,7 +290,7 @@ int curl_con_query_url(struct sip_msg* _m, char *connection, char* _url, char* _
 
 	/* TODO: Concatenate URL in connection with URL given in function */
 	return curL_query_url(_m, urlbuf, _result, usernamebuf, passwordbuf, (contenttype ? contenttype : "text/plain"), _post,
-		conn->timeout, conn->http_follow_redirect, 0, 0 );
+		conn->timeout, conn->http_follow_redirect, 0, (unsigned int) maxdatasize );
 }
 
 




More information about the sr-dev mailing list