Re: HttpRequest: weird use case
| From: | Matt Kynx | Date: | Thu, 05 Jul 2012 02:53:47 +0000 |
| Subject: | Re: HttpRequest: weird use case | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-9573@lists.php.net to get a copy of this message | ||
Gmail + clumsy keyboard shortcut = send. Arse. Caught mid edit. And
Rasmus, just saw your response. Thanks...
On Thu, Jul 5, 2012 at 1:35 AM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
>
> 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
Woah! But I'm trying to stream_register_wrapper(). I just can't see
how to get to $stream from my stream_open() or stream_write(). Am I
missing something?
More on use case...
Say I'm babysitting 300,000+ lines of legacy PHP code. Some of it
talks to the file system. That's moving onto rackspace/cloudfiles. I
can change the prefix from '/var/www/data' to 'rscf://data' in just
one place in the code. I want the wrapper to take care of (most, some,
ha!) of the rest.
FWIW I've got a (mostly) working implementation of the stream wrapper
using Zend_Http_Client and Zend_Service_Rackspace, but it's a bit of a
hack [1]. Rackspace docs are here [2].
If there's any way to expose something like startRequest(), addBody(),
..., endRequest(), readResponse() I'd be overjoyed. As I would if
there was another way of doing it.
Matt
1. https://github.com/kynx/zf1/blob/master/library/Zend/Service/Rackspace/Files/Stream.php
2. http://docs.rackspace.com/files/api/v1/cf-devguide/content/Chunked_Transfer_Encoding-d1e2092.html