a testapp.pm#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('<?xml version="1.0" encoding="utf-8" ?> <D:propfind xmlns:D="DAV:"> <D:prop> <D:creationdate/> <D:displayname/> <D:getcontentlength/> <D:getcontenttype/> <D:getetag/> <D:getlastmodified/> <D:resourcetype/> </D:prop> </D:propfind>'); ## 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";
and the server to run it: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 '<pre>'.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();
In reply to Re^2: Are all .cgi helper modules unfit for http methods common in REST?
by isync
in thread Are all .cgi helper modules unfit for http methods common in REST?
by isync
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |