use Net::ICAP::Message; $msg = new Net::ICAP::Message; $rv = $msg->parse($fh); @errors = $obj->error; $value = $obj->header($name); %headers = $obj->getHeaders; $reqheader = $obj->reqhdr; $resheader = $obj->reshdr; ($type, $body) = $obj->body; $trailer = $obj->trailer; $version = $obj->version; $ieof = $obj->ieof; $msg = Net::ICAP::Message->new( headers => { Date => $date, Expires => $exp, }, ); $rv = $obj->body($type, $body); $rv = $obj->header($name, $value); $rv = $obj->setHeaders(%headers); $rv = $obj->reqhdr($text); $rv = $obj->reshdr($text); $rv = $obj->body($type, $text); $rv = $obj->trailer($text); $rv = $obj->version($version); $rv = $obj->ieof($bool); $rv = $msg->generate($fh); @errors = $obj->error;
o Start/Status line o ICAP headers o HTTP Request/Response headers o HTTP Body o HTTP trailer
To that end, this class automatically verifies valid ICAP header names (but not values), as well as extracting and validating the message body as per the Encapsulated header's values. It, obviously, has to know how to perform chunked encoding & decoding as well.
Net::ICAP::Message is also a message generator ahd, as such, can construct encoded messages based on the data handed to it.
As a base class this is not meant to be used directly.
($type, $body) = $obj->body; $rv = $obj->body($type, $body);
Sets or gets the body type and content. Type must be a value consisting of either ICAP_REQ_BODY, ICAP_RES_BODY, ICAP_OPT_BODY, or ICAP_NULL_BODY. The body is assumed to be in raw (NOT chunked encoded) format.
$obj->error($msg); @errors = $obj->error;
Adds an error message to the internal array, or retrieves an array of string error messages. This internal array is reset with every call to the parse method.
$value = $obj->header($name); $rv = $obj->header($name, $value);
This method gets or sets a named header. The header named must be recognized as a valid ICAP header. Setting any valid header to a either undef or a zero-length string will cause the header to be deleted.
%headers = $obj->getHeaders;
This method retrieves all ICAP headers set to date.
$rv = $obj->setHeaders(%headers);
This method sets the ICAP headers en masse. All previous headers are purged, and invalid headers ignored. This will return false if invalid headers are declared. Passing it an empty hash will effectively be a no-op.
$rv = $obj->parse($ref);
This method reads from the passed reference and attempts to parse the content. The passed reference can be either a scalar reference, a file handle, or an IO::Handle object. In the case of a scalar reference the read is destructive in that every line read (terminated by \\r\\n) is deleted from the strings content.
In the event of a parsing error this method will simply stop reading and return false. This means you may have additional input that needs to be drained before you can effectively issue a response.
$rv = $obj->generate($ref);
This method generates an ICAP message based on the internal state data. It accepts a reference to write to, which can be either a scalar reference, a file handle, or an IO::Handle object. In the case of a scalar reference it does not erase any previous contents, it appends to it.
This method automatically adds the Date header if it isn't already present.
$rv = $obj->reqhdr($text); $header = $obj->reqhdr;
This method gets or sets the HTTP request header.
$rv = $obj->reshdr($text); $header = $obj->reshdr;
This method gets or sets the HTTP response header.
$rv = $obj->reshdr($text); $header = $obj->reshdr;
This method gets or sets the HTTP headers which were passed as part of the HTTP trailer, rather than in the actual header block itself.
$rv = $obj->version($version); $method = $obj->version;
This method gets or sets the ICAP protocol version string. It does perform validation of the string and will ignore any unknown strings.
$rv = $obj->ieof($val); $ieof = $obj->ieof;
This sets or detects whether an ieof marker should be (or was) sent during chunked (de|en)coding.
(c) 2013, Arthur Corliss (corliss@digitalmages.com)
Copyright © 1997 - 2016, Arthur Corliss, all rights reserved.