Re: HttpRequest: weird use case

From: Date: Thu, 05 Jul 2012 00:35:05 +0000
Subject: Re: HttpRequest: weird use case
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-9572@lists.php.net to get a copy of this message
On 07/04/2012 05:20 PM, Matt Kynx wrote: > Heya, > > I'm working on a stream wrapper for Rackspace Cloudfiles. It's got a > REST interface, which brings me here. > > Imagine I've got a clever script to save something from a stream to a > container in cloudfiles. Using it might look like: > > $ mysqldump -a | gzip -c | cfpipe.php /container/path/to/backup.sql.gz > > All cfphipe.php does is copy(STDIN, 'rscf://container/path/to/backup.sql.gz'). > > Current implementations either hold the whole stream in memory or save > it to a temp file. Rackspace supports sending the files using > Transfer-Encoding: chunked, which avoids this overhead. What I need to > do is: > > authenticate > open connection > send headers with Transfer-Enconding: chunked > stream chunk > see if total transfered > > 5. stream chunk > ...... > nnn. stream last chunk > nnn+1. read response and compare checksum > Can't you just use Curl? Something along the lines of: curl_setopt($ch, CURLOPT_UPLOAD, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Transfer-Encoding: chunked')); curl_setopt($ch, CURLOPT_READFUNCTION, function($ch, $fd, $length) use ($stream) { return fread($stream, $length); }); -Rasmus

« previous php.pecl.dev (#9572) next »