note 111975 added to function.curl-setopt

From: Date: Thu, 18 Apr 2013 16:29:53 +0000
Subject: note 111975 added to function.curl-setopt
Groups: php.notes 
Request: Send a blank email to php-notes+get-194533@lists.php.net to get a copy of this message
Another note addressing the issues with servers that have open_basedir and safe mode turned on. Such an issue spawns the following E_WARNING: Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set After looking through the notes, most of the proposed manual implementations were kind of clunky and in some cases just didn't work at all. Most importantly (in my case), was the behaviour of the 302 Header. Anyway, here's the code I ended up using which has worked well for me in all cases so far, it even addresses the issue that caused FOLLOWLOCATION to be turned off in some cases :) EDIT: Unfortunately the code itself is deemed "too long" for PHP's note system. I've uploaded it to a few paste sites below so hopefully the links will live for a while at least. http://pastebin.com/aaJtPy1j http://pastie.org/7646116 Use it as a replacement for curl_exec. For example: <?php $ch = curl_init("http://php.net"); var_dump(curl_exec_follow($ch, 9001)); curl_close($ch); ?> ---- Server IP: 69.147.83.199 Probable Submitter: 124.169.248.1 ---- Manual Page -- http://php.net/manual/en/function.curl-setopt.php Edit -- https://master.php.net/note/edit/111975 Del: integrated -- https://master.php.net/note/delete/111975/integrated Del: useless -- https://master.php.net/note/delete/111975/useless Del: bad code -- https://master.php.net/note/delete/111975/bad+code Del: spam -- https://master.php.net/note/delete/111975/spam Del: non-english -- https://master.php.net/note/delete/111975/non-english Del: in docs -- https://master.php.net/note/delete/111975/in+docs Del: other reasons-- https://master.php.net/note/delete/111975 Reject -- https://master.php.net/note/reject/111975 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#194533) next »