ID: 43468 Updated by: [EMAIL PROTECTED] Reported By: peter at petersmit dot eu -Status: Open +Status: Feedback Bug Type: cURL related Operating System: Ubuntu Linux Gutsy Gibbon -PHP Version: 5.2.latest +PHP Version: 5.2.6 New Comment:
Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ And provide the full configure line you used if the snapshot does not work. Previous Comments: ------------------------------------------------------------------------ [2008-12-10 07:09:35] peter at petersmit dot eu Sorry, not confirmed I was checking it whit my own website address in the example code and everything looked fine. However with example.org or google.com it's not working! ------------------------------------------------------------------------ [2008-12-10 01:55:55] dan dot hitt at gmail dot com I can reproduce the bug. I downloaded the link provided on the bug by jani (php 5.2 snapshot). I built php (and had to also download and build libcurl). My exact configuration line for the php was: ./configure --prefix=/home/danh/staging/php/2008_09_12_c --with-curl=/home/danh/staging/curl/2008_09_12 where the funky directory name is where i installed the curl i built. (For the curl i used no options in the configuration except where to install it.) My system is ubuntu 7.10. It would be terrific to fix the bug because curl is so useful and having arbitrary streams is so useful: at least streams to memory. Thanks everybody for your efforts on refining php. ------------------------------------------------------------------------ [2008-02-13 22:16:29] quickshiftin at gmail dot com i have discovered that this does work, partially, for some urls. im not sure what is preventing this from working on all urls, but even for ones where it does work, the entire result is not placed in the buffer. here is a modification of peters code, which illustrates 2 urls that work partially, one is the google translate 'api', the other is php.net. <?php #$c = curl_init("http://example.com"); #$c = curl_init("http://google.com/translate_t?langpair=en%7Cfr&text=newspaper"); $c = curl_init("http://php.net"); $st = fopen('php://memory', 'r'); curl_setopt($c, CURLOPT_FILE, $st); curl_setopt($c, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.11) Gecko/20080115 Firefox/2.0.0.11'); if(!curl_exec($c)) die ("error: ".curl_error($c)); curl_close($c); rewind($st); /* $str = fgets($st); var_dump($str); */ echo stream_get_contents($st); #echo "Content|".htmlspecialchars(stream_get_contents($st))."|/Content"; fclose($st); ?> ------------------------------------------------------------------------ [2007-12-01 10:00:25] peter at petersmit dot eu Description: ------------ If you use a php://memory stream in combination with curl, nothing is written to the stream. A filestream works fine. Reproduce code: --------------- <?php $c = curl_init("http://example.com"); $st = fopen("php://memory", "r+"); curl_setopt($c, CURLOPT_FILE, $st); if(!curl_exec($c)) die ("error: ".curl_error($c)); rewind($st); echo "Content|".htmlspecialchars(stream_get_contents($st))."|/Content"; fclose($st); ?> Expected result: ---------------- Content|The content of example.org|/Content Actual result: -------------- Content||/Content ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43468&edit=1