Subject: | Allow filehandles or filesystem destinations for resource fetches |
From: | mcrawfor [...] cpan.org |
As I begin to get some very very big responseContent
for my RESTfull http server in XML format, I got some
problems with the memory use by the perl script (the system use
many swap in/out).
As REST::Client use LWP::UserAgent with $ua->request(...)
or $ua->simple_request(...) , I saw that it's possible to store
directly the responseContent in a file or using a callback :
1) replace line 492:
my @attributes = qw(Host Key Cert Ca Timeout Follow
Useragent Pkcs12 Pkcs12password);
by:
my @attributes = qw(Host Key Cert Ca Timeout Follow
Useragent Pkcs12 Pkcs12password ContentFile);
2) replace line 375:
my $res = $self->getFollow ?
$ua->request($req) :
$ua->simple_request($req);
by:
my $res = $self->getFollow ?
$ua->request($req,$self->getContentFile) :
$ua->simple_request($req,$self->getContentFile);
The REST Client can store the responseContent in a file as:
$client->setContentFile( "FileName" );
or using a callback:
$client->setContentFile( \&callback_http );