NAME
ASP4::UserAgent - Execute ASP4 requests without a web server.
SYNOPSIS
NOTE: 99.99% of the time you will access this via ASP4::API.
my HTTP::Response $res = $api->ua->get('/index.asp?foo=bar');
my $res = $api->ua->post('/handlers/user.login', [
username => 'willy',
password => 'wonka',
]);
my $res = $api->ua->upload('/handlers/file.upload', [
foo => 'bar',
baz => 'bux',
file => ['/home/john/avatar.jpg']
]);
# Some form testing:
my ($form) = HTML::Form->parse( $res->content, '/' );
$form->find_input('username')->value('bob');
my $res = $api->ua->submit_form( $form );
# Add/remove a cookie:
$api->ua->add_cookie( "the-boss" => "me" );
$api->remove_cookie( "the-boss" );
DESCRIPTION
Enables unit-testing ASP4 applications by providing the ability to execuite web pages from your code, without a webserver.
PUBLIC METHODS
get( $url )
Calls $url
and returns the HTTP::Response result.
post( $url, $args )
Calls $url
with $args
and returns the HTTP::Response result.
upload( $url, $args )
Calls $url
with $args
and returns the HTTP::Response result.
submit_form( HTML::Form $form )
Submits the $form
and returns the HTTP::Response result.
add_cookie( $name, $value )
Adds the cookie to all subsequent requests.
remove_cookie( $name )
Removes the cookie (if it exists).