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.5
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

If it still does not work, please provide the full configure line you
have used.


Previous Comments:
------------------------------------------------------------------------

[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

Reply via email to