HTTP::Response::OnDisk - HTTP::Response That Writes To Disk
use HTTP::Response::OnDisk; my $r = HTTP::Response::OnDisk->new($rc, $message, $headers, $content); my $r = HTTP::Response::OnDisk->new($rc, $message, $headers, $content, { dir => '/var/blah' } ); # Change the default storage path HTTP::Response::OnDisk->default_dir('/var/blah');
HTTP::Response::OnDisk is an API-compatible replacement for HTTP::Response, whose purpose is to store the content into disk instead of memory. This greatly reduces overhead on long-running processes, such as crawlers like Gungho.
Code, message, and headers are fairly harmless in comparison to the content, so they are stored in memory. Content is stored on a temporary file disk, which is cleaned up when the response is freed.
When set, changes the default directory where the data is stored.
Creates a new HTTP::Response::OnDisk instance. Accepts the same parameters as HTTP::Response, plus an optional fifth hashref, where you may specify the following:
The directory where the temporary file is stored. See default_dir() to change the default directory path.
Sets/gets the content. Internally this accesses the underlying temporary file storage. If called in void context, attempts to avoid reading from the storage.
Adds content to the end of buffer.
Returns the File::Temp object that contains the buffer. Note that when accessing this, you should probably do a seek() to ensure you are at the right location in the file.
Returns the string representation of the object.
Clones the object.
Returns the status code.
Given a string, parses it and creates a new HTTP::Response::OnDisk instance
This doesn't make sense in HTTP::Response::OnDisk, so is intentionally not implemented. It will croak if used.
Attempts to decode the content based on Content-Transfer-Encoding, and the character set specified. Note that this method internally behaves quite differently from that of HTTP::Response.
For now this actually overwrites the internal buffer. If you care enough about memory to use this module, you shouldn't be doing stuff that requires reading the entire buffer out anyways. Let this method take care of the content, and access it later.
These methods are proxied to HTTP::Headers object.
HTTP::Response
Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
To install HTTP::Response::OnDisk, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Response::OnDisk
CPAN shell
perl -MCPAN -e shell install HTTP::Response::OnDisk
For more information on module installation, please visit the detailed CPAN module installation guide.