ASP4
view release on metacpan or search on metacpan
lib/ASP4/Request.pm view on Meta::CPAN
package ASP4::Request;
use strict;
use warnings 'all';
sub new
{
my ($class, %args) = @_;
my $cgi = $class->context->cgi;
my $s = bless {
%args,
form => {
(
map {
# CGI->Vars joins multi-value params with a null byte. Which sucks.
# To avoid that behavior, we do this instead:
my @val = map { $cgi->unescape( $_ ) } ( $cgi->param($_) );
$cgi->unescape($_) => scalar(@val) > 1 ? \@val : shift(@val)
} $cgi->param
),
(
map {
# CGI->Vars joins multi-value params with a null byte. Which sucks.
# To avoid that behavior, we do this instead:
my @val = map { $cgi->unescape( $_ ) } ( $cgi->url_param($_) );
$cgi->unescape($_) => scalar(@val) > 1 ? \@val : shift(@val)
} $cgi->url_param
),
},
}, $class;
return $s;
}# end new()
sub context { ASP4::HTTPContext->current }
# Not documented - for a reason (want to deprecate):
sub Form { shift->{form} }
# Not documented - for a reason (want to deprecate):
sub QueryString { shift->context->cgi->query_string() }
sub Cookies
{
my ($s, $name) = @_;
$name ? $s->context->cgi->cookie( $name ) : $s->context->cgi->cookie;
}# end Cookies()
sub ServerVariables { $ENV{ $_[1] } }
sub FileUpload
{
my ($s, $field) = @_;
my $ifh = $s->context->cgi->upload($field)
or return;
my %info = ( );
if( my $upInfo = eval { $s->context->cgi->uploadInfo( $ifh ) } )
{
no warnings 'uninitialized';
%info = (
ContentType => $upInfo->{'Content-Type'},
FileHandle => $ifh,
FileName => $s->{form}->{ $field } . "",
ContentDisposition => $upInfo->{'Content-Disposition'},
);
}
else
( run in 0.894 second using v1.01-cache-2.11-cpan-39bf76dae61 )