Daisuke Maki > HTTP-Response-OnDisk-0.02002 > HTTP::Response::OnDisk

Download:
HTTP-Response-OnDisk-0.02002.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.02002   Source  

NAME ^

HTTP::Response::OnDisk - HTTP::Response That Writes To Disk

SYNOPSIS ^

  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');

DESCRIPTION ^

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.

CLASS METHODS ^

default_dir

When set, changes the default directory where the data is stored.

METHODS ^

new $code, $message, $headers, $content, $opts

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:

dir

The directory where the temporary file is stored. See default_dir() to change the default directory path.

content

Sets/gets the content. Internally this accesses the underlying temporary file storage. If called in void context, attempts to avoid reading from the storage.

add_content

Adds content to the end of buffer.

storage

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.

as_string

Returns the string representation of the object.

clone

Clones the object.

code

Returns the status code.

current_age

fresh_until

freshness_lifetime

is_fresh

parse

Given a string, parses it and creates a new HTTP::Response::OnDisk instance

status_line

base

is_success

is_info

is_redirect

is_error

content_ref

This doesn't make sense in HTTP::Response::OnDisk, so is intentionally not implemented. It will croak if used.

decoded_content

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.

PROXIED METHODS ^

These methods are proxied to HTTP::Headers object.

authorization

authorization_basic

clear

client_date

content_encoding

content_language

content_length

content_type

date

expires

from

header

header_field_names

if_modified_since

if_unmodified_since

init_header

last_modified

proxy_authenticate

proxy_authorization

proxy_authorization_basic

push_header

referer

referrer

remove_content_headers

remove_header

scan

server

title

user_agent

warning

www_authenticate

SEE ALSO ^

HTTP::Response

AUTHOR ^

Copyright (c) 2007 Daisuke Maki <daisuke@endeworks.jp>

LICENSE ^

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

syntax highlighting: