Apache2-ASP
view release on metacpan or search on metacpan
lib/Apache2/ASP/Request.pm view on Meta::CPAN
}# end foreach()
return $s->{_form} = $form;
}
else
{
return $s->{_form} || { };
}# end if()
}# end Form()
#==============================================================================
sub QueryString
{
my $s = shift;
return $s->context->r->args;
}# end QueryString()
#==============================================================================
sub Cookies
{
my $s = shift;
return { } unless $s->context->headers_in->{cookie};
my %out = ( );
foreach my $item ( split /;\s*/, $s->context->headers_in->{cookie} )
{
my ( $name, $val ) = map { $s->context->cgi->unescape( $_ ) } split /\=/, $item;
$out{$name} = $val;
}# end foreach()
@_ ? $out{$_[0]} : \%out;
}# end Cookies()
#==============================================================================
sub FileUpload
{
my ($s, $field) = @_;
confess "Request.FileUpload called without arguments"
unless defined($field);
my $cgi = $s->context->cgi;
my $ifh = $cgi->upload($field);
my %info = ();
my $upInfo = { };
if( $cgi->isa('Apache2::ASP::SimpleCGI') )
{
no warnings 'uninitialized';
my $up = $cgi->upload_info( $field, 'mime' )
or return;
%info = (
ContentType => $up,
FileHandle => $ifh,
FileName => $s->Form->{ $field } . "",
'ContentDisposition' => 'attachment',
# Mime-Header is deprecated as of v2.46
# 'Mime-Header' => $cgi->upload_info( $field, 'mime' ),
);
}
else
{
$upInfo = $cgi->uploadInfo( $ifh )
or return;
no warnings 'uninitialized';
%info = (
ContentType => $upInfo->{'Content-Type'},
FileHandle => $ifh,
FileName => $s->Form->{ $field } . "",
'ContentDisposition' => $upInfo->{'Content-Disposition'},
# Mime-Header is deprecated as of v2.46
# 'Mime-Header' => $upInfo->{type},
);
}# end if()
return wantarray ? %info : \%info;
}# end FileUpload()
#==============================================================================
sub DESTROY
{
my $s = shift;
undef(%$s);
}# end DESTROY()
1;# return true:
=pod
=head1 NAME
Apache2::ASP::Request - Incoming request object.
=head1 SYNOPSIS
my $form_args = $Request->Form;
my $querystring = $Request->QueryString;
my $cookies = $Request->Cookies;
my $cookie = $Request->Cookies('name');
my $vars = $Request->ServerVariables;
my $var = $Request->ServerVariables('HTTP_HOST');
=head1 DESCRIPTION
The request represents a wrapper around incoming form, querystring and cookie data.
=head1 PUBLIC METHODS
=head2 ServerVariables( [$name] )
( run in 0.964 second using v1.01-cache-2.11-cpan-e1769b4cff6 )