]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
func_curl: Add 'followlocation' option to CURLOPT()
authorSean Bright <sean.bright@gmail.com>
Fri, 10 Jan 2020 19:30:20 +0000 (14:30 -0500)
committerSean Bright <sean.bright@gmail.com>
Mon, 13 Jan 2020 14:25:03 +0000 (08:25 -0600)
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

doc/CHANGES-staging/func_curl.txt [new file with mode: 0644]
funcs/func_curl.c

diff --git a/doc/CHANGES-staging/func_curl.txt b/doc/CHANGES-staging/func_curl.txt
new file mode 100644 (file)
index 0000000..fa9ad97
--- /dev/null
@@ -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.
index 06a8b5354ef18b4d4370ab5fc35fb7c48fdda172..af6b7b09f7eb53b6b22e5a6e1ee518a88d131df4 100644 (file)
@@ -88,6 +88,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                        <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>
@@ -109,7 +112,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                                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>
@@ -247,6 +252,9 @@ static int parse_curlopt_key(const char *name, CURLoption *key, enum optiontype
        } 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;
@@ -798,6 +806,7 @@ static struct ast_custom_function acf_curlopt = {
 "  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"