view release on metacpan or search on metacpan
2.14 2009-01-25
- <asp:Content/> tags inside of pages that use MasterPages were not being passed
TrapInclude or Include arguments (i.e. $Response->Include("/page.asp", { arg1 => "foo" }) ).
2.13 2009-01-25
- Apache2::ASP::MediaManager did not provide any content-type header for
file types not listed in MIME::Types (eg: *.ogv). Now "application/octet-stream"
is returned when MIME::Types does not return anything.
2.12 2009-01-20
- The "Cookies" HTTP header was not properly handled in the Test UserAgent.
- Incoming HTTP headers were comingled with outgoing HTTP headers in HTTPContext.
2.11 2009-01-10
- Several fixes to cookie behavior problems.
- Removed <module>Class::DBI::Lite</module> from apache2-asp-config.xml.
2.10 2009-01-05
- The Set-Cookie header for session state no longer includes the domain parameter.
2.09 2008-12-12
- Apache2::ASP::API->get("/") or get("/folder-name/") works as expected (without
forcing you to include "/index.asp" at the end.
- Added 05.00-folder-uri.t to make sure that "/folder-name/" URI's are supported
via the programmatic API.
- After testing, we remove /tmp/asp_*
2.08 2008-12-10
- Updated the POD for Apache2::ASP::API.
- Hotfix for config. Was crashing unless settings.request_filters was defined.
1.25 2008-02-05
- Added the concept of "Request Filters" as Apache2::ASP::RequestFilter. These
are useful for centralizing authorization code. Request Filters are stackable.
- Added config.web_application.settings.request_filters.filter and documented it in
the documentation for Apache2::ASP::RequestFilter.
- Request Filters will be considered experimental until v1.26 is released.
1.24 2008-01-17
- Fixes a problem with $Request->Cookies( $name ) that caused it to return undef
instead of the cookie's value.
- When Response->Include( $nonexistent_file ) is called, a simple diagnostic is
printed to the buffer ("Cannot Response.Include '$file' - the file does not exist")
and Carp::cluck dumps a stacktrace to STDERR.
- If $Response->End or $Response->Redirect is called in Script_OnStart then the script
is no longer processed.
1.23 2007-12-27
- Apache2::ASP::Config now only adds PAGE_CACHE and $Config->handler_root to @INC
if they have not already been added before.
lib/Apache2/ASP/Request.pm view on Meta::CPAN
#==============================================================================
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);
lib/Apache2/ASP/Request.pm view on Meta::CPAN
=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] )
If called with no arguments, returns C<%ENV>. If called with an argument, returns
C<$ENV{$name}> where C<$name> is the value of the argument.
=head2 Cookies( [$name] )
If called with no arguments, returns a hash of all cookies. Otherwise, returns
the value of the cookie named C<$name>.
=head1 PUBLIC PROPERTIES
=head2 Form
Returns a hashref of all querystring and form data.
lib/Apache2/ASP/Response.pm view on Meta::CPAN
my $res = $subcontext->execute( $args );
my $result = $subcontext->{r}->{buffer};
$subcontext->DESTROY;
undef( $subcontext );
return $result;
}# end TrapInclude()
#==============================================================================
sub Cookies
{
$_[0]->context->headers_out->{'set-cookie'};
}# end Cookies()
#==============================================================================
sub AddCookie
{
my $s = shift;
my ($name, $val, $path, $expires) = @_;
die "Usage: Response.AddCookie(name, value [, path [, expires ]])"
unless defined($name) && defined($val);
$path ||= '/';
$expires ||= time() + ( 60 * 30 );
my $expire_date ||= time2str( $expires );
my $cookie = join '=', map { $s->context->cgi->escape( $_ ) } ( $name => $val );
$s->context->headers_out->push_header( 'set-cookie' => "$cookie; path=$path; expires=$expire_date" );
}# end AddCookie()
#==============================================================================
sub AddHeader
{
my ($s, $name, $val) = @_;
return unless defined($name) && defined($val);
return $s->context->headers_out->{ $name } = $val;
lib/Apache2/ASP/Response.pm view on Meta::CPAN
=head2 Expires( [$minutes] )
Default 0
=head2 ExpiresAbsolute( [$http_date] )
=head2 Declined( )
Returns C<-1>.
=head2 Cookies( )
Returns all outgoing cookies for this response.
=head2 Headers( )
Returns all outgoing headers for this response.
=head2 IsClientConnected( )
Returns true if the client is still connected, false otherwise.
lib/Apache2/ASP/Response.pm view on Meta::CPAN
=head2 Include( $path, \%args )
Executes the script located at C<$path>, passing along C<\%args>. Output is
included as part of the current script's output.
=head2 TrapInclude( $path, \%args )
Executes the script located at C<$path>, passing along C<\%args>, and returns
the response as a string.
=head2 AddCookie( $name => $value )
Adds a cookie to the header.
=head2 AddHeader( $name => $value )
Adds a header to the response.
=head2 DeleteHeader( $name )
Removes an outgoing header.
lib/Apache2/ASP/SessionStateManager.pm view on Meta::CPAN
{
my ($s) = @_;
my $cookiename = $s->context->config->data_connections->session->cookie_name;
no warnings 'uninitialized';
if( my ($id) = $ENV{HTTP_COOKIE} =~ m/$cookiename\=([a-f0-9]+)/ )
{
return $id;
}
elsif( ($id) = $s->context->r->headers_in->{Cookie} =~ m/$cookiename\=([a-f0-9]+)/ )
{
return $id;
}
else
{
return;
}# end if()
}# end parse_session_id()
lib/Apache2/ASP/SessionStateManager.pm view on Meta::CPAN
}# end new_session_id()
#==============================================================================
sub write_session_cookie
{
my $s = shift;
my $state = $s->context->config->data_connections->session;
my $cookiename = $state->cookie_name;
my $domain = eval { $state->cookie_domain } ? " domain=" . $state->cookie_domain . ";" : "";
$s->context->r->err_headers_out->{'Set-Cookie'} = "$cookiename=$s->{SessionID}; path=/; $domain";
# If we weren't given an HTTP cookie value, set it here.
# This prevents subsequent calls to 'parse_session_id()' to fail:
$ENV{HTTP_COOKIE} ||= '';
if( $ENV{HTTP_COOKIE} !~ m/\b$cookiename\=.*?\b/ )
{
my @cookies = split /;/, $ENV{HTTP_COOKIE};
push @cookies, "$cookiename=$s->{SessionID}";
$ENV{HTTP_COOKIE} = join ';', @cookies;
}# end if()
lib/Apache2/ASP/Test/UserAgent.pm view on Meta::CPAN
no warnings 'uninitialized';
%ENV = ( DOCUMENT_ROOT => $ENV{DOCUMENT_ROOT} );
}
$ENV{REQUEST_METHOD} = 'POST';
my $cgi = $s->_setup_cgi( $req );
$ENV{CONTENT_TYPE} = 'application/x-www-form-urlencoded';
my $r = Apache2::ASP::Mock::RequestRec->new();
$r->uri( $uri );
$r->args( $cgi->{querystring} );
$r->{headers_in}->{Cookie} = $ENV{HTTP_COOKIE};
$s->context->setup_request( $r, $cgi );
return $s->_setup_response( $s->context->execute() );
}# end post()
#==============================================================================
sub upload
{
my ($s, $uri, $args) = @_;
lib/Apache2/ASP/Test/UserAgent.pm view on Meta::CPAN
}
my $req = POST $uri, Content_Type => 'form-data', Content => $args;
$ENV{REQUEST_METHOD} = 'POST';
$ENV{CONTENT_TYPE} = $req->headers->{'content-type'};
my $cgi = $s->_setup_cgi( $req );
$ENV{CONTENT_TYPE} = 'multipart/form-data';
my $r = Apache2::ASP::Mock::RequestRec->new();
$r->uri( $uri );
$r->args( $cgi->{querystring} );
$r->{headers_in}->{Cookie} = $ENV{HTTP_COOKIE};
$s->context->setup_request( $r, $cgi );
require Apache2::ASP::UploadHook;
my $handler_resolver = $s->context->config->web->handler_resolver;
$s->context->config->load_class( $handler_resolver );
my $hook_obj = Apache2::ASP::UploadHook->new(
handler_class => $handler_resolver->new()->resolve_request_handler( $uri ),
);
my $hook_ref = sub { $hook_obj->hook( @_ ) };
lib/Apache2/ASP/Test/UserAgent.pm view on Meta::CPAN
%ENV = ( DOCUMENT_ROOT => $ENV{DOCUMENT_ROOT} );
}
$ENV{REQUEST_METHOD} = uc( $req->method );
my $cgi = $s->_setup_cgi( $req );
$ENV{CONTENT_TYPE} = $form->enctype ? $form->enctype : 'application/x-www-form-urlencoded';
$ENV{HTTP_REFERER} = $temp_referrer;
my $r = Apache2::ASP::Mock::RequestRec->new();
$r->uri( $req->uri );
$r->args( $cgi->{querystring} );
$r->{headers_in}->{Cookie} = $ENV{HTTP_COOKIE};
$s->context->setup_request( $r, $cgi );
return $s->_setup_response( $s->context->execute() );
}# end submit_form()
#==============================================================================
sub get
{
lib/Apache2/ASP/Test/UserAgent.pm view on Meta::CPAN
no warnings 'uninitialized';
%ENV = ( DOCUMENT_ROOT => $ENV{DOCUMENT_ROOT} );
}
$ENV{REQUEST_METHOD} = 'GET';
my $cgi = $s->_setup_cgi( $req );
$ENV{CONTENT_TYPE} = 'application/x-www-form-urlencoded';
my $r = Apache2::ASP::Mock::RequestRec->new();
$r->uri( $uri );
$r->args( $cgi->{querystring} );
$r->{headers_in}->{Cookie} = $ENV{HTTP_COOKIE};
$s->context->setup_request( $r, $cgi );
return $s->_setup_response( $s->context->execute() );
}# end get()
#==============================================================================
sub add_cookie
{
lib/Apache2/ASP/Test/UserAgent.pm view on Meta::CPAN
{
my ($uri_no_args) = split /\?/, $req->uri;
$ENV{SCRIPT_FILENAME} = $s->context->config->web->www_root . $uri_no_args;
$ENV{SCRIPT_NAME} = $uri_no_args;
}# end unless()
# User-Agent:
$req->header( 'User-Agent' => 'test-useragent v1.0' );
$ENV{HTTP_USER_AGENT} = 'test-useragent v1.0';
# Cookies:
my @cookies = ();
while( my ($name,$val) = each(%{ $s->{cookies} } ) )
{
next unless $name && $val;
push @cookies, "$name=" . Apache2::ASP::SimpleCGI->escape($val);
}# end while()
$req->header( 'Cookie' => join ';', @cookies ) if @cookies;
$ENV{HTTP_COOKIE} = join ';', @cookies;
$ENV{DOCUMENT_ROOT} = $docroot
if $docroot;
if( $ENV{REQUEST_METHOD} =~ m/^post$/i )
{
# Set up the basic params:
return Apache2::ASP::SimpleCGI->new(
querystring => $ENV{QUERY_STRING},
body => $req->content,
t/010-coverage/060-request.t view on Meta::CPAN
use Apache2::ASP::API;
my $api; BEGIN { $api = Apache2::ASP::API->new }
can_ok( $api, 'config' );
ok( $api, 'got an API object' );
isa_ok( $api, 'Apache2::ASP::API' );
$api->ua->get('/index.asp');
# Cookies:
{
ok(
$api->context->request->Cookies,
'request.cookies'
);
ok(
$api->context->request->Cookies('session-id'),
'request.cookies(session-id)'
);
}
# QueryString:
{
$api->ua->get('/index.asp?foo=bar');
is(
$api->context->request->QueryString => 'foo=bar',
t/010-coverage/070-response.t view on Meta::CPAN
ok(
my $res = $api->context->response->TrapInclude( $api->context->server->MapPath('/inc.asp' ) ),
'got response.trapinclude content'
);
like $res,
qr/\s+Included\! 1\:2\:3\:4\:5\:6\:7\:8\:9\:10\s+/,
'TrapInclude content looks right';
}
# Cookies:
{
is( $api->context->response->Cookies => undef, 'response.cookies starts out undef' );
$api->context->response->AddCookie(
'test-cookie' => '123'
);
like(
$api->context->response->Cookies, qr/test\-cookie\=123; path\=\/; expires\=.*?\s+GMT/i,
'response.Cookies looks right after adding a single cookie'
);
$api->context->response->AddCookie(
'another-cookie' => 'foobar'
);
# Now we should have an arrayref of cookies:
is(
ref($api->context->response->Cookies) => 'ARRAY',
'two cookies makes an array'
);
like(
$api->context->response->Cookies->[0], qr/test\-cookie\=123; path\=\/; expires\=.*?\s+GMT/i,
'The first cookie is in the first position'
);
like(
$api->context->response->Cookies->[1], qr/another\-cookie\=foobar; path\=\/; expires\=.*?\s+GMT/i,
'The second cookie is in the second position'
);
# Test out the other options:
$api->context->response->AddCookie(
'path-cookie' => 'pathtest' => '/path/'
);
like(
$api->context->response->Cookies->[2], qr/path\-cookie\=pathtest; path\=\/path\/; expires\=.*?\s+GMT/i,
'Path cookie looks right and is in the correct position'
);
my $five_minutes = time2str( time() + 300 );
$api->context->response->AddCookie(
'expire-cookie' => 'expiretest' => '/expires/' => time() + 300
);
is(
$api->context->response->Cookies->[3], "expire-cookie=expiretest; path=/expires/; expires=$five_minutes",
'Expiration cookie looks right and is in the correct position'
);
}
# DeleteHeader:
{