#perl
use LWP::UserAgent;
use HTTP::Request;
my $ua = LWP::UserAgent->new;
## build request
print "PROPFIND:\n";
$req = HTTP::Request->new('PROPFIND' => 'http://localhost:4242/');
$req->header( 'Depth' => '1' );
$req->content('
');
## fire request through ua and get a response back
my $res = $ua->request($req);
if ($res->is_success) {
print $res->status_line ."\n". $res->headers->as_string . $res->content;
}else{
print $res->status_line, "\n";
}
print "\n\n";
## build request
print "PUT:\n";
$req = HTTP::Request->new('PUT' => 'http://localhost:4242/test.txt'); ## update
$req->content('1234567890');
## Pass request to the user agent and get a response back
my $res = $ua->request($req);
if ($res->is_success) {
print $res->status_line ."\n". $res->headers->as_string . $res->content;
}else{
print $res->status_line, "\n";
}
print "\n\n";
####
package testapp;
use base 'CGI::Application';
use Data::Dumper;
sub setup {
my $self = shift;
$self->start_mode('index');
$self->run_modes('index' => 'index');
}
## update
# sub cgiapp_get_query {
# my $self = shift;
# require CGI::Simple;
# return CGI::Simple->new();
# }
sub index {
my $self = shift;
return ''.Dumper($self);
}
1;
##
##
#!/usr/bin/perl
use CGI::Application::Server;
use testapp;
my $server = CGI::Application::Server->new(4242);
# $server->document_root('./htdocs');
$server->entry_points({
'/' => 'testapp',
'/test.txt' => 'testapp',
});
$server->run();