NAME

Mail::MtPolicyd::Request - the request object

VERSION

version 2.05

ATTRIBUTES

attributes

Contains an HashRef with all attributes of the request.

To retrieve a single attribute the attr method could be used:

$obj->attr('sender');

session

Contains a HashRef with all values stored in the session.

mtpolicyd will persist the content of this HashRef across requests with the same instance_id.

server

Contains the Net::Server object of mtpolicyd.

type

The type of the request. Postfix will always use 'smtpd_access_policy'.

use_caching

Could be used to disable caching. Only used within the unit tests.

METHODS

dump_attr

Returns an string to dump the content of a request.

get($variable_name)

Retrieve value of a session or request variable.

The format for the variable name is

(<scope>:)?<variable>

If no scope is given it default to the request scope.

Valid scopes are:

session, s

Session variables.

request, r

Request attributes.

For example:

$r->get('request:sender'); # retrieve sender from request
$r->get('r:sender');       # short format
$r->get('sender');         # scope defaults to request

$r->get('session:user_policy'); # retrieve session variable user_policy
$r->get('s:user_policy');       # the same

new_from_fh($fh)

An object constructor for creating an request object with the content read for the supplied filehandle $fh.

Will die if am error ocours:

error parsing request

A line in the request could not be parsed.

while reading request: <io-error>

The filehandle had an error while reading the request.

connection closed by peer

Connection has been closed while reading the request.

could not parse request

The client did not send a complete request.

do_cached( $key, $sub )

This method will execute the function reference give in $sub and store the return values in $key within the session. If there is already a cached result stored within $key of the session it will return the content instead of calling the reference again.

Returns an Array with the return values of the function call.

Example:

my ( $ip_result, $info ) = $r->do_cached('rbl-'.$self->name.'-result',
  sub { $self->_rbl->check( $ip ) } );

is_already_done( $key )

This function will raise an flag with name of $key within the session and return true if the flag is already set. False otherwise.

This could be used to prevent scores or headers from being applied a second time.

Example:

if( defined $self->score && ! $r->is_already_done('rbl-'.$self->name.'-score') ) {
  $self->add_score($r, $self->name => $self->score);
}

is_attr_defined

Returns true if all given attribute names are defined and non-empty.

AUTHOR

Markus Benning <ich@markusbenning.de>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.

This is free software, licensed under:

The GNU General Public License, Version 2, June 1991