logo       

Re: RFC HTTP::Cache module: msg#00052

lang.perl.modules.lwp

Subject: Re: RFC HTTP::Cache module

On tor, 2004-09-30 at 14:30, Randal L. Schwartz wrote:
> The module that I've designed a half dozen times in my head but never
> implemented would simply overload LWP::UserAgent's "simple_request"
> method with one that did caching transparently.
>

Ok, I'll give it a shot. I experimented with how to overload
simple_request and came up with the following. Does it seem right so
far?

use strict;

use LWP::UserAgent;

BEGIN
{
print "Installing\n";
$LWP::Simple::FULL_LWP++;
my $org_simple_request = \&LWP::UserAgent::simple_request;

{
no warnings;
*LWP::UserAgent::simple_request = sub
{
my($self, $request, $arg, $size) = @_;

print "Overloaded\n";
return &$org_simple_request( $self, $request, $arg, $size );
}
}
}
1;

/Mattias





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise