5 use lib "$FindBin::Bin/../lib";
7 use Test::More tests => 12;
8 use Catalyst::Test 'TestAppOnDemand';
10 use Catalyst::Request;
12 use HTTP::Request::Common;
14 # Test a simple POST request to make sure body parsing
15 # works in on-demand mode.
18 if ( $ENV{CATALYST_SERVER} ) {
19 skip "Using remote server", 12;
26 'http://localhost/body/query_params?wibble=wobble',
27 'Content-Type' => 'application/x-www-form-urlencoded',
28 'Content' => 'foo=bar&baz=quux'
31 my $expected = { wibble => 'wobble' };
33 ok( my $response = request($request), 'Request' );
34 ok( $response->is_success, 'Response Successful 2xx' );
39 eval '$params = ' . $response->content,
44 is_deeply( $params, $expected, 'Catalyst::Request query parameters' );
51 'http://localhost/body/params?wibble=wobble',
52 'Content-Type' => 'application/x-www-form-urlencoded',
53 'Content' => 'foo=bar&baz=quux'
56 my $expected = { foo => 'bar', baz => 'quux', wibble => 'wobble' };
58 ok( my $response = request($request), 'Request' );
59 ok( $response->is_success, 'Response Successful 2xx' );
63 eval '$params = ' . $response->content,
68 is_deeply( $params, $expected, 'Catalyst::Request body and query parameters' );
71 # Test reading chunks of the request body using $c->read
76 'http://localhost/body/read',
77 'Content-Type' => 'text/plain',
78 'Content' => 'x' x 105_000
81 my $expected = '10000|10000|10000|10000|10000|10000|10000|10000|10000|10000|5000';
83 ok( my $response = request($request), 'Request' );
84 ok( $response->is_success, 'Response Successful 2xx' );
85 is( $response->content_type, 'text/plain', 'Response Content-Type' );
86 is( $response->content, $expected, 'Response Content' );