Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > Curl doesn't handle memory stream
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 30th October 20:34
peter
External User
 
Posts: 1
Default Curl doesn't handle memory stream



Hello,

I've got quite a strange problem with the curl library.

The following code does output Content||\Content instead of
Content|example.orgoutput|\Content

$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($s t))."|/Content";
fclose($st);


If I use a file stream instead it works as expected:

$c = curl_init("http://example.com");

$file = "/tmp/phptest".rand()."";
touch($file);
$st = fopen($file, "r+");

curl_setopt($c, CURLOPT_FILE, $st);

if(!curl_exec($c)) die ("error: ".curl_error($c));

rewind($st);
echo "Content|".htmlspecialchars(stream_get_contents($s t))."|/Content";
fclose($st);
unlink($file);


What's the problem? Does PHP not support memory streams in Curl?

Peter
  Reply With Quote


 


2 31st October 01:57
peter
External User
 
Posts: 1
Default Curl doesn't handle memory stream



Hello,

I don't know or it's allowed to kick thread, but I give it a try.
Does somebody have any idea why the Curl extension doesn't handle
memory streams?

Regards,

Peter
  Reply With Quote
3 31st October 01:58
quickshiftin
External User
 
Posts: 1
Default Curl doesn't handle memory stream


im curious to know where you discovered
php://memory
was a valid stream; i looked through the online manual and found no
reference to it.
nor did i find anything from google. i did encounter it in the php source,
but with no
useful documentation.
a reference of all the streams that are valid with the php:// scheme would
be helpful.

getting to your problem, i think this could perhaps be a bug.
you might file a bug report and post your code along with it; unless
somebody has a
better idea

-nathan
  Reply With Quote
4 31st October 01:58
peter
External User
 
Posts: 1
Default Curl doesn't handle memory stream


This reference to php:// streams you can find on
http://www.php.net/manual/en/wrappers.php.php . If nobody has a
solution I think I'll report it as a bug tomorrow.

Peter
  Reply With Quote
Reply


Thread Tools
Display Modes




666