[Asterisk-code-review] func_curl: Add 'followlocation' option to CURLOPT() (asterisk[16])

Joshua Colp asteriskteam at digium.com
Tue Jan 14 12:35:59 CST 2020


Joshua Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13614 )

Change subject: func_curl: Add 'followlocation' option to CURLOPT()
......................................................................

func_curl: Add 'followlocation' option to CURLOPT()

We allow for 'maxredirs' to be set, but this value is ignored when
followlocation is not enabled which, by default, it is not.

ASTERISK-17491 #close
Reported by: candrews

Change-Id: I96a4ab0142f2fb7d2e96ff976f6cf7b2982c761a
---
A doc/CHANGES-staging/func_curl.txt
M funcs/func_curl.c
2 files changed, 15 insertions(+), 1 deletion(-)

Approvals:
  Jaco Kroon: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Joshua Colp: Approved for Submit



diff --git a/doc/CHANGES-staging/func_curl.txt b/doc/CHANGES-staging/func_curl.txt
new file mode 100644
index 0000000..fa9ad97
--- /dev/null
+++ b/doc/CHANGES-staging/func_curl.txt
@@ -0,0 +1,5 @@
+Subject: func_curl
+
+A new option, followlocation, can now be enabled with the CURLOPT()
+dialplan function. Setting this will instruct cURL to follow 3xx
+redirects, which it does not by default.
diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index af54f7d..fcc626a 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -110,6 +110,9 @@
 					<enum name="dnstimeout">
 						<para>Number of seconds to wait for DNS to be resolved</para>
 					</enum>
+					<enum name="followlocation">
+						<para>Whether or not to follow HTTP 3xx redirects (boolean)</para>
+					</enum>
 					<enum name="ftptext">
 						<para>For FTP URIs, force a text transfer (boolean)</para>
 					</enum>
@@ -131,7 +134,9 @@
 						server response</para>
 					</enum>
 					<enum name="maxredirs">
-						<para>Maximum number of redirects to follow</para>
+						<para>Maximum number of redirects to follow. The default is -1,
+						which allows for unlimited redirects. This only makes sense when
+						followlocation is also set.</para>
 					</enum>
 					<enum name="proxy">
 						<para>Hostname or IP address to use as a proxy server</para>
@@ -269,6 +274,9 @@
 	} else if (!strcasecmp(name, "proxyuserpwd")) {
 		*key = CURLOPT_PROXYUSERPWD;
 		*ot = OT_STRING;
+	} else if (!strcasecmp(name, "followlocation")) {
+		*key = CURLOPT_FOLLOWLOCATION;
+		*ot = OT_BOOLEAN;
 	} else if (!strcasecmp(name, "maxredirs")) {
 		*key = CURLOPT_MAXREDIRS;
 		*ot = OT_INTEGER;
@@ -858,6 +866,7 @@
 "  cookie         - Send cookie with request [none]\n"
 "  conntimeout    - Number of seconds to wait for connection\n"
 "  dnstimeout     - Number of seconds to wait for DNS response\n"
+"  followlocation - Follow HTTP 3xx redirects (boolean)\n"
 "  ftptext        - For FTP, force a text transfer (boolean)\n"
 "  ftptimeout     - For FTP, the server response timeout\n"
 "  header         - Retrieve header information (boolean)\n"

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13614
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I96a4ab0142f2fb7d2e96ff976f6cf7b2982c761a
Gerrit-Change-Number: 13614
Gerrit-PatchSet: 3
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jaco Kroon <jaco at uls.co.za>
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20200114/7788f467/attachment.html>


More information about the asterisk-code-review mailing list