[asterisk-bugs] [JIRA] (ASTERISK-17491) CURLOPT() needs a "followlocation" parameter / "maxredirs" doesn't do anything

John Fawcett (JIRA) noreply at issues.asterisk.org
Sun Jun 28 12:27:32 CDT 2015


    [ https://issues.asterisk.org/jira/browse/ASTERISK-17491?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=226688#comment-226688 ] 

John Fawcett commented on ASTERISK-17491:
-----------------------------------------

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;
 }


> CURLOPT() needs a "followlocation" parameter / "maxredirs" doesn't do anything
> ------------------------------------------------------------------------------
>
>                 Key: ASTERISK-17491
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-17491
>             Project: Asterisk
>          Issue Type: New Feature
>          Components: Functions/func_curl
>    Affects Versions: 1.8.3
>            Reporter: candrews
>
> 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.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list