[Home]

Summary:ASTERISK-17491: CURLOPT() needs a "followlocation" parameter / "maxredirs" doesn't do anything
Reporter:candrews (candrews)Labels:patch
Date Opened:2011-03-01 13:15:23.000-0600Date Closed:2020-01-14 12:30:46.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/func_curl
Versions:1.8.3 13.18.4 Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) ast11_func_curl_redirects_and_tls.patch
Description:I noticed that the CURL function will not follow redirects. According to http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTFOLLOWLOCATION you need to set the CURLOPT_FOLLOWLOCATION in order for CURL to follow redirects, and that is not set according to the source code: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_curl.c?view=markup

This is especially interesting seeing as how there is a "maxredirs" CURLOPT parameter. According to the CURL documentation at http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTMAXREDIR :
"This option only makes sense if the CURLOPT_FOLLOWLOCATION is used at the same time."

I suggest that a new CURLOPT parameter "followlocation" be added to add the redirect following feature and fix the currently broken "maxredirs" option.

****** ADDITIONAL INFORMATION ******

Note that this is not a feature request - "maxredirect" (which already exists) is currently broken - and I'm suggesting a way to fix that.
Comments:By: John Fawcett (johnfawcett) 2015-06-28 12:25:45.319-0500

Although probably not the most elegant way to solve it, simplest is always to set the FOLLOWLOCATION option.

That way the existing maxredirs option can then be used to control redirection.

--- asterisk-11.18.0/funcs/func_curl.c 2015-06-04 02:44:42.000000000 +0200
+++ asterisk-11.18.0-patch/funcs/func_curl.c 2015-06-28 18:09:53.236502937 +0200
@@ -553,6 +553,7 @@
curl_easy_setopt(*curl, CURLOPT_TIMEOUT, 180);
curl_easy_setopt(*curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(*curl, CURLOPT_USERAGENT, global_useragent);
+ curl_easy_setopt(*curl, CURLOPT_FOLLOWLOCATION, 1L);

return 0;
}


By: Steven Wheeler (swheeler) 2016-04-20 09:50:10.910-0500

Here's a patch which fixes this issue in Asterisk 11 (certified-asterisk-11.6-cert11 to be specific).

This adds two new options to the CURLOPT() function:
* {{followlocation}} Whether or not to follow any Location header in a HTTP 3xx response. This accepts boolean values.
* {{sslversion}} Set the preferred SSL/TLS version. This accepts the following values:
**  {{default}} Use the cURL default setting.
** {{tlsv1}} Use TLSv1.x.
** {{sslv2}} Use SSLv2.
** {{sslv3}} Use SSLv3.
**  {{tlsv1.0}} Use TLSv1.0, added in cURL v7.34.0.
**  {{tlsv1.1}} Use TLSv1.1, added in cURL v7.34.0.
**  {{tlsv1.2}} Use TLSv1.2, added in cURL v7.34.0.

By: Friendly Automation (friendly-automation) 2020-01-14 12:30:47.241-0600

Change 13587 merged by Joshua Colp:
func_curl: Add 'followlocation' option to CURLOPT()

[https://gerrit.asterisk.org/c/asterisk/+/13587|https://gerrit.asterisk.org/c/asterisk/+/13587]

By: Friendly Automation (friendly-automation) 2020-01-14 12:32:47.768-0600

Change 13615 merged by Friendly Automation:
func_curl: Add 'followlocation' option to CURLOPT()

[https://gerrit.asterisk.org/c/asterisk/+/13615|https://gerrit.asterisk.org/c/asterisk/+/13615]

By: Friendly Automation (friendly-automation) 2020-01-14 12:36:34.823-0600

Change 13616 merged by Joshua Colp:
func_curl: Add 'followlocation' option to CURLOPT()

[https://gerrit.asterisk.org/c/asterisk/+/13616|https://gerrit.asterisk.org/c/asterisk/+/13616]

By: Friendly Automation (friendly-automation) 2020-01-14 12:36:51.529-0600

Change 13614 merged by Joshua Colp:
func_curl: Add 'followlocation' option to CURLOPT()

[https://gerrit.asterisk.org/c/asterisk/+/13614|https://gerrit.asterisk.org/c/asterisk/+/13614]