cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Request To Memory Buffer

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 8 Jun 2007 12:51:57 -0700

On Fri, Jun 08, 2007 at 11:05:20AM +0300, Uygar Gümüs wrote:
> Thanks for quick reply but that example shows saving to memory. My case is about reading from that memory block like reading from server url.
>
> For example
> I saved data for http:///xxx.y to buffer as shown in example and than at second attempt to request http:///xxx.y do not make a curl request to server but read data from that buffer with curl callbacks (write callback actually) My code should be like this...
[...]
> I am doing this because there are some code blocks which assumes that "data will be given from CURLOPT_WRITEFUNCTION callback, not directly" and i don`t want to change that part because of possible changes by developers of that parts.

If you want the caching to be (semi)transparent to the application, you
could just intercept the curl_easy_perform call and set_easy_setopt call to
set the URL, and call the write callback functions yourself if it's a URL
you've stored elsewhere.

But a far easier scenario is to run a caching HTTP server alongside your
application that takes care of all the caching for you. I believe that
Squid, for example, can be configured to cache only in memory and not
to disk. That makes the caching completely transparent to your application.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2007-06-08