Apache2-API
view release on metacpan or search on metacpan
lib/Apache2/API/Request/Params.pm view on Meta::CPAN
my $body;
my $return = 0;
# try-catch
local $@;
eval
{
if( $self->body_status != 0 )
{
$ERROR = "APR::Request::body_status returned non-zero (" . $self->body_status . ")";
$return++;
}
$body = $self->body or ++$return;
};
return if( $return );
if( $@ )
{
return( $self->error( "Unable to get the APR::Request body objet: $@" ) );
}
# So further call on this object will be handled by Apache2::API::Request::Params::Field below
$body->param_class( 'Apache2::API::Request::Upload' );
if( @_ )
{
my @uploads = grep( $_->upload, $body->get( @_ ) );
return( wantarray() ? @uploads : $uploads[0] );
}
return map{ $_->upload ? $_->name : () } values( %$body ) if( wantarray() );
return( $body->uploads( $self->pool ) );
}
sub uploads
{
my $self = shift( @_ );
my $body;
my $return = 0;
# try-catch
local $@;
eval
{
if( $self->body_status != 0 )
{
$ERROR = "APR::Request::body_status returned non-zero (" . $self->body_status . ")";
$return++;
}
$body = $self->body or ++$return;
};
return if( $return );
if( $@ )
{
return( $self->error( "Unable to get the APR::Request body objet: $@" ) );
}
# So further call on this object will be handled by Apache2::API::Request::Params::Field below
$body->param_class( __PACKAGE__ . '::Field' );
return( $body->uploads( $self->pool ) );
}
1;
# NOTE: POD
__END__
=encoding utf8
=head1 NAME
Apache2::API::Request::Params - Apache2 Request Fields Object
=head1 SYNOPSIS
use Apache2::API::Request::Params;
## $r is the Apache2::RequestRec object
my $req = Apache2::API::Request::Params->new(
request => $r,
# pool of 2Mb
brigade_limit => 2097152,
disable_uploads => 0,
# For example: 3Mb
read_limit => 3145728,
temp_dir => '/home/me/my/tmp'
upload_hook => sub
{
my( $upload, $new_data ) = @_;
# do something
},
);
my $form = $req->args;
# but it is more efficient to call $request->params with $request being a Apache2::API::Request object
my @args = $req->args;
my $val = $req->args( 'first_name' );
my $status = $req->args_status;
my @names = $req->body;
my @vals = $req->body( 'field' );
my $status = $req->body_status;
$req->brigade_limit( 1024 );
my $bucket = $req->bucket_alloc;
# No upload please
$req->disable_uploads( 1 );
# Returns a APR::Request::Cookie::Table object
my $jar = $req->jar;
my $cookie = $req->jar( 'cookie_name' );
my @all = $req->jar( 'cookie_name' );
my $status = $req->jar_status;
# Returns a APR::Request::Param::Table object
my $object = $req->param;
my $val = $req->param( 'first_name' );
my @multi_choice_values = $req->param( 'multi_choice_field' );
# Note that $self->request->param( 'multi_choice_field' ) would return an array reference
# $self being your object inheriting from Apache2::API
my $status = $req->param_status;
$req->parse;
# Returns a APR::Pool object
my $pool = $req->pool;
my $limit = $req->read_limit;
( run in 0.820 second using v1.01-cache-2.11-cpan-39bf76dae61 )