Re: Curl doesn't handle memory stream

From: Date: Thu, 29 Nov 2007 12:56:45 +0000
Subject: Re: Curl doesn't handle memory stream
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-265215@lists.php.net to get a copy of this message
On Nov 27, 2007 11:43 PM, Peter Smit <peter@petersmit.eu> wrote: > 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($st))."|/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($st))."|/Content"; > fclose($st); > unlink($file); > > > What's the problem? Does PHP not support memory streams in Curl? > > Peter > 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

« previous php.general (#265215) next »