2 use warnings FATAL => 'all';
5 eval { require HTTP::Request::AsCGI }
7 : (skip_all => 'No HTTP::Request::AsCGI')
11 use Web::Simple 'PostTest';
15 $_[1]->{bar} ||= 'EMPTY';
17 [ "Content-type" => "text/plain" ],
18 [ join(' ',@{$_[1]}{qw(foo bar)}) ]
24 use HTTP::Request::Common qw(GET POST);
26 my $app = PostTest->new;
30 my $c = HTTP::Request::AsCGI->new($request)->setup;
36 my $get = run_request(GET 'http://localhost/');
38 cmp_ok($get->code, '==', 404, '404 on GET');
40 my $no_body = run_request(POST 'http://localhost/');
42 cmp_ok($no_body->code, '==', 404, '404 with empty body');
44 my $no_foo = run_request(POST 'http://localhost/' => [ bar => 'BAR' ]);
46 cmp_ok($no_foo->code, '==', 404, '404 with no foo param');
48 my $no_bar = run_request(POST 'http://localhost/' => [ foo => 'FOO' ]);
50 cmp_ok($no_bar->code, '==', 200, '200 with only foo param');
52 is($no_bar->content, 'FOO EMPTY', 'bar defaulted');
54 my $both = run_request(
55 POST 'http://localhost/' => [ foo => 'FOO', bar => 'BAR' ]
58 cmp_ok($both->code, '==', 200, '200 with both params');
60 is($both->content, 'FOO BAR', 'both params returned');