
Dicop::Request -- an object containing one message/request/answer

use Dicop::Request;
use Dicop::Request::Pattern;
my $pattern1 = Dicop::Request::Pattern->new( ... );
my $pattern2 = Dicop::Request::Pattern->new( ... );
$request = new Dicop::Request (
id => 'req0001',
data => 'req_0000=cmd_status;client_5',
patterns => [ $pattern1, $pattern2, ... ],
);
print $request->error(); # request was ok?

perl5.8.3, Dicop::Base, Dicop::Item, Dicop::Event

Exports nothing.

Class to represent a request. A request is both something the client sends to the server as well as the return answer from the server. A more better appropriate name would be "message".

Get/set error message. Returns empty string in case of no error.
Create an exact copy of yourself.
$request->check ( $data, $validator);
Applies self-check and set error string on error.
Get/set the request's id:
$request->request_id('req0003'); # set
print $request->request_id(); # get and print
Returns the request as a compact request string that can be sent as an URL parameter to the server:
$request->as_request_string();
This will give something like:
req0002=cmd_status;type_main
$request->pattern();
Return the request pattern that this request matched, or undef for none (in case of errors). See Dicop::Request::Pattern.
$request->class();
Return the class of the request. The type stems from the pattern this request matches and is defined in an external textfile together with the pattern. See Dicop::Request::Pattern.
$request->type();
Return the type of the request. The type stems from the pattern this request matches and is defined in an external textfile together with the pattern. See Dicop::Request::Pattern.
$request->output();
Return the output type of the request. The type stems from the pattern this request matches and is defined in an external textfile together with the pattern. See Dicop::Request::Pattern.
$request->title();
Return the output title for requests of output() eq 'html'. The type stems from the pattern this request matches and is defined in an external textfile together with the pattern. See Dicop::Request::Pattern.
$request->template_name();
Return the template file that should be used for this request. The template file name stems from the pattern this request matches and is defined in an external textfile together with the pattern. See Dicop::Request::Pattern.
$request->auth();
Return a flag on whether this request needs a password or not. The flag stems from the pattern this request matches and is defined in an external textfile together with the pattern. See Dicop::Request::Pattern.
Set a field of the request object to another value:
$equest->field('foo';'bar'); # set $request->{foo} to 'bar'
Return a field of the object as an ASCII string suitable for HTML output:
$result->get_as_string('foo');
Return a field of the object as an hexified string, or as a fallback, as normal string via get_as_string. The hexify happens only for certain special fields, all other are returned as simple strings:
$result->get_as_hex('foo');
Change a field's value after checking that the field can be changed (via can_change) and checking the new value. If the new value does not conform to the expected format, it will be silently modifed (f.i. invalid characters might be removed) and then the change will happen:
$object->change('foo','bar'); # will change $object->{foo} to bar
# if foo can be changed
my $carry = $request->carry();
Return a list of fields that the form must include to carry over.
Return true if the field's value can be changed.
die ("Can not change field $field\n") if !$object->can_change($field);
if ($request->is_form())
{
...
}
Returns true if the request is of the tested type (form, auth, info or request). Returns false if the request is invalid (e.g. an error occured).
my ($sort_dir, $sort_by) = $request->sort_order();
Return sort direction and the field to sort on, for example 'up','id').

None known yet.

(c) Bundesamt fuer Sicherheit in der Informationstechnik 1998-2006
DiCoP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
See http://www.bsi.de/ for more information.